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 ShippingContainer_1 = require("../persistent-classes/ShippingContainer");
class ShippingContainerService {
constructor() {
/*** generated service methods here ***/
this.findAllShippingContainers = () => __awaiter(this, void 0, void 0, function* () {
return yield ShippingContainer_1.ShippingContainer.findAll({ raw: true });
});
this.findAllShippingContainersByOid = (Oid) => __awaiter(this, void 0, void 0, function* () {
return yield ShippingContainer_1.ShippingContainer.findAll({ where: { Oid }, raw: true });
});
this.findOneShippingContainerByOid = (Oid) => __awaiter(this, void 0, void 0, function* () {
return yield ShippingContainer_1.ShippingContainer.findOne({ where: { Oid }, raw: true });
});
this.updateShippingContainer = (shippingcontainer) => __awaiter(this, void 0, void 0, function* () {
return yield ShippingContainer_1.ShippingContainer.update(Object.assign({}, shippingcontainer), { where: { Oid: shippingcontainer['Oid'] } });
});
this.saveShippingContainer = (shippingcontainer) => __awaiter(this, void 0, void 0, function* () {
return yield new ShippingContainer_1.ShippingContainer(Object.assign({}, shippingcontainer)).save();
});
this.batchSaveShippingContainers = (shippingcontainers) => __awaiter(this, void 0, void 0, function* () {
return yield ShippingContainer_1.ShippingContainer.bulkCreate(shippingcontainers.map((x) => {
// do work here
return Object.assign({}, x);
}));
});
this.deleteShippingContainerByOid = (Oid) => __awaiter(this, void 0, void 0, function* () {
return yield ShippingContainer_1.ShippingContainer.destroy({ where: { Oid } });
});
/************************** Methods not attached to 'Controller' below here ******************************/
this.findAllShippingContainersByColumns = (columns) => __awaiter(this, void 0, void 0, function* () {
return yield ShippingContainer_1.ShippingContainer.findAll({ where: Object.assign({}, columns), raw: true });
});
}
}
exports.default = new ShippingContainerService();
//# sourceMappingURL=ShippingContainer.service.js.map