account.js 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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 Account = db_1["default"].define('account', {
  17. key: {
  18. type: sequelize_1.DataTypes.STRING,
  19. primaryKey: true
  20. },
  21. format: sequelize_1.DataTypes.STRING,
  22. about: sequelize_1.DataTypes.TEXT
  23. });
  24. Account.findAllWithIncludes = function () {
  25. return this.findAll({
  26. include: [
  27. { association: 'validated', attributes: ['id', 'timestamp'] },
  28. { model: db_1["default"].models.member, attributes: ['handle'] },
  29. ]
  30. });
  31. };
  32. Account.findByIdWithIncludes = function (id) {
  33. return this.findByPk(id, {
  34. include: [
  35. { association: 'validated', attributes: ['id', 'timestamp'] },
  36. { model: db_1["default"].models.member, attributes: ['handle'] },
  37. ]
  38. });
  39. };
  40. Account.findWithIncludes = function (args) {
  41. return this.findAll(__assign(__assign({}, args), { include: [
  42. { association: 'validated', attributes: ['id', 'timestamp'] },
  43. { model: db_1["default"].models.member, attributes: ['handle'] },
  44. ] }));
  45. };
  46. exports["default"] = Account;