moderation.js 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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 Moderation = db_1["default"].define('moderation', {
  17. created: sequelize_1.DataTypes.INTEGER,
  18. createdAt: sequelize_1.DataTypes.DATE,
  19. rationale: sequelize_1.DataTypes.TEXT
  20. });
  21. Moderation.findAllWithIncludes = function () {
  22. return this.findAll({
  23. include: [
  24. { model: db_1["default"].models.category },
  25. { model: db_1["default"].models.post, include: [{ association: 'author' }] },
  26. { association: 'creator' },
  27. { association: 'moderator' },
  28. ]
  29. });
  30. };
  31. Moderation.findByIdWithIncludes = function (id, args) {
  32. return this.findByPk(id, __assign(__assign({}, args), { include: [
  33. { model: db_1["default"].models.category },
  34. { model: db_1["default"].models.post, include: [{ association: 'author' }] },
  35. { association: 'creator' },
  36. { association: 'moderator' },
  37. ] }));
  38. };
  39. Moderation.findWithIncludes = function (args) {
  40. return this.findAll(__assign(__assign({}, args), { include: [
  41. { model: db_1["default"].models.category },
  42. { model: db_1["default"].models.post, include: [{ association: 'author' }] },
  43. { association: 'creator' },
  44. { association: 'moderator' },
  45. ] }));
  46. };
  47. exports["default"] = Moderation;