era.js 2.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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 Era = db_1["default"].define('era', {
  17. id: {
  18. type: sequelize_1.DataTypes.INTEGER,
  19. primaryKey: true
  20. },
  21. waiting: sequelize_1.DataTypes.INTEGER,
  22. active: sequelize_1.DataTypes.INTEGER,
  23. slots: sequelize_1.DataTypes.INTEGER,
  24. timestamp: sequelize_1.DataTypes.DATE,
  25. stake: sequelize_1.DataTypes.DECIMAL
  26. });
  27. Era.findAllWithIncludes = function () {
  28. return this.findAll({
  29. include: [
  30. {
  31. model: db_1["default"].models.block,
  32. attributes: ['id', 'blocktime', 'timestamp'],
  33. include: [
  34. {
  35. association: 'validator',
  36. attributes: ['key'],
  37. include: [
  38. { model: db_1["default"].models.member, attributes: ['id', 'handle'] },
  39. ]
  40. },
  41. { model: db_1["default"].models.event },
  42. ]
  43. },
  44. ]
  45. });
  46. };
  47. Era.findByIdWithIncludes = function (id) {
  48. return this.findByPk(id, {
  49. include: [
  50. {
  51. model: db_1["default"].models.block,
  52. attributes: ['id', 'blocktime', 'timestamp'],
  53. include: [
  54. {
  55. association: 'validator',
  56. attributes: ['key'],
  57. include: [
  58. { model: db_1["default"].models.member, attributes: ['id', 'handle'] },
  59. ]
  60. },
  61. { model: db_1["default"].models.event },
  62. ]
  63. },
  64. ]
  65. });
  66. };
  67. Era.findWithIncludes = function (args) {
  68. return this.findAll(__assign(__assign({}, args), { include: [
  69. {
  70. model: db_1["default"].models.block,
  71. attributes: ['id', 'blocktime', 'timestamp'],
  72. include: [
  73. {
  74. association: 'validator',
  75. attributes: ['key'],
  76. include: [
  77. { model: db_1["default"].models.member, attributes: ['id', 'handle'] },
  78. ]
  79. },
  80. { model: db_1["default"].models.event },
  81. ]
  82. },
  83. ] }));
  84. };
  85. exports["default"] = Era;