UNPKG

sequelize-ts-boilerplate

Version:

A REST API scaffolding tool designed to scale and easily generate CRUD endpoints based on database schema design

46 lines 3.08 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); const NotificationFormat_1 = require("../persistent-classes/NotificationFormat"); class NotificationFormatService { constructor() { /*** generated service methods here ***/ this.findAllNotificationFormats = () => __awaiter(this, void 0, void 0, function* () { return yield NotificationFormat_1.NotificationFormat.findAll({ raw: true }); }); this.findAllNotificationFormatsByOid = (Oid) => __awaiter(this, void 0, void 0, function* () { return yield NotificationFormat_1.NotificationFormat.findAll({ where: { Oid }, raw: true }); }); this.findOneNotificationFormatByOid = (Oid) => __awaiter(this, void 0, void 0, function* () { return yield NotificationFormat_1.NotificationFormat.findOne({ where: { Oid }, raw: true }); }); this.updateNotificationFormat = (notificationformat) => __awaiter(this, void 0, void 0, function* () { return yield NotificationFormat_1.NotificationFormat.update(Object.assign({}, notificationformat), { where: { Oid: notificationformat['Oid'] } }); }); this.saveNotificationFormat = (notificationformat) => __awaiter(this, void 0, void 0, function* () { return yield new NotificationFormat_1.NotificationFormat(Object.assign({}, notificationformat)).save(); }); this.batchSaveNotificationFormats = (notificationformats) => __awaiter(this, void 0, void 0, function* () { return yield NotificationFormat_1.NotificationFormat.bulkCreate(notificationformats.map((x) => { // do work here return Object.assign({}, x); })); }); this.deleteNotificationFormatByOid = (Oid) => __awaiter(this, void 0, void 0, function* () { return yield NotificationFormat_1.NotificationFormat.destroy({ where: { Oid } }); }); /************************** Methods not attached to 'Controller' below here ******************************/ this.findAllNotificationFormatsByColumns = (columns) => __awaiter(this, void 0, void 0, function* () { return yield NotificationFormat_1.NotificationFormat.findAll({ where: Object.assign({}, columns), raw: true }); }); } } exports.default = new NotificationFormatService(); //# sourceMappingURL=NotificationFormat.service.js.map