3
1

proposalvote.ts 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. import db from '../db'
  2. import { DataTypes } from 'sequelize'
  3. const ProposalVote = db.define('proposalvote', {
  4. vote: DataTypes.STRING,
  5. })
  6. ProposalVote.findAllWithIncludes = function () {
  7. return this.findAll({
  8. include: [
  9. { model: db.models.member, attributes: ['handle'] },
  10. { model: db.models.consul },
  11. { model: db.models.proposal, attributes: ['title'] },
  12. ],
  13. })
  14. }
  15. ProposalVote.findByIdWithIncludes = function (
  16. id: number,
  17. args?: { where: any }
  18. ) {
  19. return this.findByPk(id, {
  20. ...args,
  21. include: [
  22. { model: db.models.member, attributes: ['handle'] },
  23. { model: db.models.consul },
  24. { model: db.models.proposal, attributes: ['title'] },
  25. ],
  26. })
  27. }
  28. ProposalVote.findWithIncludes = function (args: { where: any }) {
  29. return this.findAll({
  30. ...args,
  31. include: [
  32. { model: db.models.member, attributes: ['handle'] },
  33. { model: db.models.consul },
  34. { model: db.models.proposal, attributes: ['title'] },
  35. ],
  36. })
  37. }
  38. export default ProposalVote