event.ts 799 B

123456789101112131415161718192021222324252627282930313233343536
  1. import db from '../db'
  2. import { DataTypes } from 'sequelize'
  3. const Event = db.define('event', {
  4. section: DataTypes.STRING,
  5. method: DataTypes.STRING,
  6. data: DataTypes.TEXT,
  7. })
  8. Event.findAllWithIncludes = function () {
  9. return this.findAll({
  10. include: [
  11. { model: db.models.block, include: [{ association: 'validator' }] },
  12. ],
  13. })
  14. }
  15. Event.findByIdWithIncludes = function (id: number, args?: { where: any }) {
  16. return this.findByPk(id, {
  17. ...args,
  18. include: [
  19. { model: db.models.block, include: [{ association: 'validator' }] },
  20. ],
  21. })
  22. }
  23. Event.findWithIncludes = function (args?: { where: any }) {
  24. return this.findAll({
  25. ...args,
  26. include: [
  27. { model: db.models.block, include: [{ association: 'validator' }] },
  28. ],
  29. })
  30. }
  31. export default Event