block.ts 667 B

12345678910111213141516171819202122232425262728293031323334
  1. import db from '../db'
  2. import { DataTypes } from 'sequelize'
  3. const Block = db.define('block', {
  4. id: {
  5. type: DataTypes.INTEGER,
  6. primaryKey: true,
  7. },
  8. timestamp: DataTypes.DATE,
  9. blocktime: DataTypes.INTEGER,
  10. })
  11. Block.findAllWithIncludes = function () {
  12. return this.findAll({
  13. include: [
  14. { model: db.models.era },
  15. { model: db.models.event },
  16. { association: 'author' },
  17. ],
  18. })
  19. }
  20. Block.findWithIncludes = function (args: { where: any }) {
  21. return this.findAll({
  22. ...args,
  23. include: [
  24. { model: db.models.era },
  25. { model: db.models.event },
  26. { association: 'author' },
  27. ],
  28. })
  29. }
  30. export default Block