councilseat.js 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. "use strict";
  2. var __assign = (this && this.__assign) || function () {
  3. __assign = Object.assign || function(t) {
  4. for (var s, i = 1, n = arguments.length; i < n; i++) {
  5. s = arguments[i];
  6. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
  7. t[p] = s[p];
  8. }
  9. return t;
  10. };
  11. return __assign.apply(this, arguments);
  12. };
  13. exports.__esModule = true;
  14. var db_1 = require("../db");
  15. var sequelize_1 = require("sequelize");
  16. var Seat = db_1["default"].define('consul', {
  17. stake: sequelize_1.DataTypes.INTEGER
  18. });
  19. Seat.findAllWithIncludes = function () {
  20. return this.findAll({
  21. include: [
  22. { model: db_1["default"].models.council },
  23. { model: db_1["default"].models.member },
  24. {
  25. association: 'votes',
  26. include: [{ model: db_1["default"].models.proposal, attributes: ['title'] }]
  27. },
  28. {
  29. association: 'voters',
  30. include: [{ model: db_1["default"].models.member, attributes: ['handle'] }]
  31. },
  32. ]
  33. });
  34. };
  35. Seat.findByIdWithIncludes = function (id, args) {
  36. return this.findByPk(id, __assign(__assign({}, args), { include: [
  37. { model: db_1["default"].models.council },
  38. { model: db_1["default"].models.member },
  39. {
  40. association: 'votes',
  41. include: [{ model: db_1["default"].models.proposal, attributes: ['title'] }]
  42. },
  43. {
  44. association: 'voters',
  45. include: [{ model: db_1["default"].models.member, attributes: ['handle'] }]
  46. },
  47. ] }));
  48. };
  49. Seat.findWithIncludes = function (args) {
  50. return this.findAll(__assign(__assign({}, args), { include: [
  51. { model: db_1["default"].models.council },
  52. { model: db_1["default"].models.member },
  53. {
  54. association: 'votes',
  55. include: [{ model: db_1["default"].models.proposal, attributes: ['title'] }]
  56. },
  57. {
  58. association: 'voters',
  59. include: [{ model: db_1["default"].models.member, attributes: ['handle'] }]
  60. },
  61. ] }));
  62. };
  63. exports["default"] = Seat;