1
0

commitment.ts 756 B

123456789101112131415161718192021222324252627282930
  1. import db from '../db'
  2. import { DataTypes } from 'sequelize'
  3. const Commitment = db.define('commitment', {
  4. round: DataTypes.INTEGER,
  5. stake: DataTypes.INTEGER,
  6. vote: DataTypes.STRING
  7. })
  8. Commitment.findAllWithIncludes = function () {
  9. return this.findAll({
  10. include: [{ model: db.models.consul }, { model: db.models.member }],
  11. })
  12. }
  13. Commitment.findByIdWithIncludes = function (id: number, args?: { where: any }) {
  14. return this.findByPk(id, {
  15. ...args,
  16. include: [{ model: db.models.consul }, { model: db.models.member }],
  17. })
  18. }
  19. Commitment.findWithIncludes = function (args: { where: any }) {
  20. return this.findAll({
  21. ...args,
  22. include: [{ model: db.models.consul }, { model: db.models.member }],
  23. })
  24. }
  25. export default Commitment