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.04 kB
JavaScript
;
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 EventRegistration_1 = require("../persistent-classes/EventRegistration");
class EventRegistrationService {
constructor() {
/*** generated service methods here ***/
this.findAllEventRegistrations = () => __awaiter(this, void 0, void 0, function* () {
return yield EventRegistration_1.EventRegistration.findAll({ raw: true });
});
this.findAllEventRegistrationsByOid = (Oid) => __awaiter(this, void 0, void 0, function* () {
return yield EventRegistration_1.EventRegistration.findAll({ where: { Oid }, raw: true });
});
this.findOneEventRegistrationByOid = (Oid) => __awaiter(this, void 0, void 0, function* () {
return yield EventRegistration_1.EventRegistration.findOne({ where: { Oid }, raw: true });
});
this.updateEventRegistration = (eventregistration) => __awaiter(this, void 0, void 0, function* () {
return yield EventRegistration_1.EventRegistration.update(Object.assign({}, eventregistration), { where: { Oid: eventregistration['Oid'] } });
});
this.saveEventRegistration = (eventregistration) => __awaiter(this, void 0, void 0, function* () {
return yield new EventRegistration_1.EventRegistration(Object.assign({}, eventregistration)).save();
});
this.batchSaveEventRegistrations = (eventregistrations) => __awaiter(this, void 0, void 0, function* () {
return yield EventRegistration_1.EventRegistration.bulkCreate(eventregistrations.map((x) => {
// do work here
return Object.assign({}, x);
}));
});
this.deleteEventRegistrationByOid = (Oid) => __awaiter(this, void 0, void 0, function* () {
return yield EventRegistration_1.EventRegistration.destroy({ where: { Oid } });
});
/************************** Methods not attached to 'Controller' below here ******************************/
this.findAllEventRegistrationsByColumns = (columns) => __awaiter(this, void 0, void 0, function* () {
return yield EventRegistration_1.EventRegistration.findAll({ where: Object.assign({}, columns), raw: true });
});
}
}
exports.default = new EventRegistrationService();
//# sourceMappingURL=EventRegistration.service.js.map