UNPKG

@jfln/marvin-db

Version:

biblioteca de objetos para normalizar o acesso a um banco mongo db

74 lines (59 loc) 3.74 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.BaseEntity = void 0; var _core = require("@mikro-orm/core"); var _mongodb = require("@mikro-orm/mongodb"); var _dec, _dec2, _dec3, _dec4, _dec5, _dec6, _dec7, _dec8, _dec9, _dec10, _class, _descriptor, _descriptor2, _descriptor3, _descriptor4, _descriptor5; function _initializerDefineProperty(target, property, descriptor, context) { if (!descriptor) return; Object.defineProperty(target, property, { enumerable: descriptor.enumerable, configurable: descriptor.configurable, writable: descriptor.writable, value: descriptor.initializer ? descriptor.initializer.call(context) : void 0 }); } function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) { var desc = {}; Object.keys(descriptor).forEach(function (key) { desc[key] = descriptor[key]; }); desc.enumerable = !!desc.enumerable; desc.configurable = !!desc.configurable; if ('value' in desc || desc.initializer) { desc.writable = true; } desc = decorators.slice().reverse().reduce(function (desc, decorator) { return decorator(target, property, desc) || desc; }, desc); if (context && desc.initializer !== void 0) { desc.value = desc.initializer ? desc.initializer.call(context) : void 0; desc.initializer = undefined; } if (desc.initializer === void 0) { Object.defineProperty(target, property, desc); desc = null; } return desc; } function _initializerWarningHelper(descriptor, context) { throw new Error('Decorating class property failed. Please ensure that ' + 'proposal-class-properties is enabled and runs after the decorators transform.'); } let BaseEntity = (_dec = (0, _core.PrimaryKey)(), _dec2 = Reflect.metadata("design:type", typeof _mongodb.ObjectId === "undefined" ? Object : _mongodb.ObjectId), _dec3 = (0, _core.SerializedPrimaryKey)(), _dec4 = Reflect.metadata("design:type", String), _dec5 = (0, _core.Property)(), _dec6 = Reflect.metadata("design:type", String), _dec7 = (0, _core.Property)({ onCreate: () => new Date() }), _dec8 = Reflect.metadata("design:type", typeof Date === "undefined" ? Object : Date), _dec9 = (0, _core.Property)({ onUpdate: () => new Date() }), _dec10 = Reflect.metadata("design:type", typeof Date === "undefined" ? Object : Date), (_class = class BaseEntity { setGuildId(guildId) { this.guildId = guildId; return this; } constructor(guildId) { _initializerDefineProperty(this, "_id", _descriptor, this); _initializerDefineProperty(this, "id", _descriptor2, this); _initializerDefineProperty(this, "guildId", _descriptor3, this); _initializerDefineProperty(this, "createdAt", _descriptor4, this); _initializerDefineProperty(this, "updatedAt", _descriptor5, this); this.guildId = guildId; } }, (_descriptor = _applyDecoratedDescriptor(_class.prototype, "_id", [_dec, _dec2], { configurable: true, enumerable: true, writable: true, initializer: null }), _descriptor2 = _applyDecoratedDescriptor(_class.prototype, "id", [_dec3, _dec4], { configurable: true, enumerable: true, writable: true, initializer: null }), _descriptor3 = _applyDecoratedDescriptor(_class.prototype, "guildId", [_dec5, _dec6], { configurable: true, enumerable: true, writable: true, initializer: null }), _descriptor4 = _applyDecoratedDescriptor(_class.prototype, "createdAt", [_dec7, _dec8], { configurable: true, enumerable: true, writable: true, initializer: function () { return new Date(); } }), _descriptor5 = _applyDecoratedDescriptor(_class.prototype, "updatedAt", [_dec9, _dec10], { configurable: true, enumerable: true, writable: true, initializer: function () { return new Date(); } })), _class)); exports.BaseEntity = BaseEntity;