1
0

proposalpost.ts 850 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. import db from '../db'
  2. import { DataTypes } from 'sequelize'
  3. const ProposalPost = db.define('proposalpost', {
  4. id: {
  5. type: DataTypes.INTEGER,
  6. primaryKey: true,
  7. },
  8. created: DataTypes.INTEGER,
  9. updated: DataTypes.INTEGER,
  10. edition: DataTypes.INTEGER,
  11. text: DataTypes.TEXT,
  12. })
  13. ProposalPost.findAllWithIncludes = function () {
  14. return this.findAll({
  15. include: [{ association: 'author', attributes: ['handle'] }],
  16. })
  17. }
  18. ProposalPost.findByIdWithIncludes = function (
  19. id: number,
  20. args?: { where: any }
  21. ) {
  22. return this.findByPk(id, {
  23. ...args,
  24. include: [{ association: 'author', attributes: ['handle'] }],
  25. })
  26. }
  27. ProposalPost.findWithIncludes = function (args: { where: any }) {
  28. return this.findAll({
  29. ...args,
  30. include: [{ association: 'author', attributes: ['handle'] }],
  31. })
  32. }
  33. export default ProposalPost