block.js 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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 Block = db_1["default"].define('block', {
  17. id: {
  18. type: sequelize_1.DataTypes.INTEGER,
  19. primaryKey: true
  20. },
  21. hash: sequelize_1.DataTypes.STRING,
  22. timestamp: sequelize_1.DataTypes.DATE,
  23. blocktime: sequelize_1.DataTypes.INTEGER
  24. });
  25. Block.findAllWithIncludes = function () {
  26. return this.findAll({
  27. include: [
  28. { model: db_1["default"].models.era },
  29. { model: db_1["default"].models.event },
  30. { association: 'validator' },
  31. ]
  32. });
  33. };
  34. Block.findByIdWithIncludes = function (id) {
  35. return this.findByPk(id, {
  36. include: [
  37. { model: db_1["default"].models.era },
  38. { model: db_1["default"].models.event },
  39. { association: 'validator' },
  40. ]
  41. });
  42. };
  43. Block.findWithIncludes = function (args) {
  44. return this.findAll(__assign(__assign({}, args), { include: [
  45. { model: db_1["default"].models.era },
  46. { model: db_1["default"].models.event },
  47. { association: 'validator' },
  48. ] }));
  49. };
  50. exports["default"] = Block;