block.ts 887 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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: 'validator' },
  17. ],
  18. })
  19. }
  20. Block.findByIdWithIncludes = function (id: number) {
  21. return this.findByPk(id, {
  22. include: [
  23. { model: db.models.era },
  24. { model: db.models.event },
  25. { association: 'validator' },
  26. ],
  27. })
  28. }
  29. Block.findWithIncludes = function (args: { where: any }) {
  30. return this.findAll({
  31. ...args,
  32. include: [
  33. { model: db.models.era },
  34. { model: db.models.event },
  35. { association: 'validator' },
  36. ],
  37. })
  38. }
  39. export default Block