UNPKG

@accounts/mikro-orm

Version:
46 lines 1.41 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.getServiceSchema = exports.getServiceCtor = exports.Service = void 0; const core_1 = require("@mikro-orm/core"); class Service { id; user; name; token; options; constructor({ name, user, password }) { this.name = name; if (user) { this.user = (0, core_1.ref)(user); } if (password) { this.options = { bcrypt: password }; } } } exports.Service = Service; const getServiceCtor = ({ abstract = false, } = {}) => { if (abstract) { Object.defineProperty(Service, 'name', { value: 'AccountsService' }); } return Service; }; exports.getServiceCtor = getServiceCtor; const getServiceSchema = ({ UserEntity, abstract = false, } = {}) => { if (abstract) { Object.defineProperty(Service, 'name', { value: 'AccountsService' }); } return new core_1.EntitySchema({ class: Service, abstract, properties: { id: { type: 'number', primary: true }, user: { kind: 'm:1', ref: true, type: UserEntity?.name ?? 'User' }, name: { type: 'string' }, token: { type: 'string', nullable: true }, options: { type: 'json', nullable: true }, }, }); }; exports.getServiceSchema = getServiceSchema; //# sourceMappingURL=Service.js.map