sequelize-ts-boilerplate
Version:
A REST API scaffolding tool designed to scale and easily generate CRUD endpoints based on database schema design
46 lines • 2.97 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 EntityAttribute_1 = require("../persistent-classes/EntityAttribute");
class EntityAttributeService {
constructor() {
/*** generated service methods here ***/
this.findAllEntityAttributes = () => __awaiter(this, void 0, void 0, function* () {
return yield EntityAttribute_1.EntityAttribute.findAll({ raw: true });
});
this.findAllEntityAttributesByOid = (Oid) => __awaiter(this, void 0, void 0, function* () {
return yield EntityAttribute_1.EntityAttribute.findAll({ where: { Oid }, raw: true });
});
this.findOneEntityAttributeByOid = (Oid) => __awaiter(this, void 0, void 0, function* () {
return yield EntityAttribute_1.EntityAttribute.findOne({ where: { Oid }, raw: true });
});
this.updateEntityAttribute = (entityattribute) => __awaiter(this, void 0, void 0, function* () {
return yield EntityAttribute_1.EntityAttribute.update(Object.assign({}, entityattribute), { where: { Oid: entityattribute['Oid'] } });
});
this.saveEntityAttribute = (entityattribute) => __awaiter(this, void 0, void 0, function* () {
return yield new EntityAttribute_1.EntityAttribute(Object.assign({}, entityattribute)).save();
});
this.batchSaveEntityAttributes = (entityattributes) => __awaiter(this, void 0, void 0, function* () {
return yield EntityAttribute_1.EntityAttribute.bulkCreate(entityattributes.map((x) => {
// do work here
return Object.assign({}, x);
}));
});
this.deleteEntityAttributeByOid = (Oid) => __awaiter(this, void 0, void 0, function* () {
return yield EntityAttribute_1.EntityAttribute.destroy({ where: { Oid } });
});
/************************** Methods not attached to 'Controller' below here ******************************/
this.findAllEntityAttributesByColumns = (columns) => __awaiter(this, void 0, void 0, function* () {
return yield EntityAttribute_1.EntityAttribute.findAll({ where: Object.assign({}, columns), raw: true });
});
}
}
exports.default = new EntityAttributeService();
//# sourceMappingURL=EntityAttribute.service.js.map