UNPKG

@jfln/marvin-db

Version:

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

54 lines (40 loc) 2.65 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SettingsChannel = void 0; var _core = require("@mikro-orm/core"); var _BaseEntity = require("../BaseEntity"); var _dec, _dec2, _dec3, _dec4, _dec5, _class, _class2, _descriptor; 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 SettingsChannel = (_dec = (0, _core.Entity)({ tableName: 'setting-channels' }), _dec2 = Reflect.metadata("design:type", Function), _dec3 = Reflect.metadata("design:paramtypes", [String, Array]), _dec4 = (0, _core.Property)({ type: 'json' }), _dec5 = Reflect.metadata("design:type", Array), _dec(_class = _dec2(_class = _dec3(_class = (_class2 = class SettingsChannel extends _BaseEntity.BaseEntity { setChannels(channels) { this.channels = channels; return this; } addChannel(channel) { this.channels.push(channel); return this; } removeChannel(channel) { this.channels = this.channels.filter(c => c.id !== channel.id); return this; } constructor(guildId, channels) { super(guildId); _initializerDefineProperty(this, "channels", _descriptor, this); this.channels = channels; } }, (_descriptor = _applyDecoratedDescriptor(_class2.prototype, "channels", [_dec4, _dec5], { configurable: true, enumerable: true, writable: true, initializer: null })), _class2)) || _class) || _class) || _class); exports.SettingsChannel = SettingsChannel;