UNPKG

@tomei/rental

Version:
67 lines 2.8 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } 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) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.JointHirerRepository = void 0; const general_1 = require("@tomei/general"); const joint_hirer_entity_1 = require("../../models/joint-hirer.entity"); class JointHirerRepository extends general_1.RepositoryBase { constructor() { super(joint_hirer_entity_1.JointHirerModel); } findByPk(id, transaction) { return __awaiter(this, void 0, void 0, function* () { try { const result = yield joint_hirer_entity_1.JointHirerModel.findByPk(id, { transaction: transaction, }); return result; } catch (error) { throw new Error(`An Error occured when fetching : ${error.message}`); } }); } delete(hirerId, dbTransaction) { return __awaiter(this, void 0, void 0, function* () { try { const options = { where: { HirerId: hirerId, }, transaction: dbTransaction, }; yield joint_hirer_entity_1.JointHirerModel.destroy(options); } catch (error) { throw new Error(`An Error occured when delete : ${error.message}`); } }); } findAndCountAll(options) { return __awaiter(this, void 0, void 0, function* () { try { let jointHirers; if (options) { jointHirers = yield joint_hirer_entity_1.JointHirerModel.findAndCountAll(options); } else { jointHirers = yield joint_hirer_entity_1.JointHirerModel.findAndCountAll(); } return jointHirers; } catch (error) { throw new Error(`An Error occured when retriving : ${error.message}`); } }); } } exports.JointHirerRepository = JointHirerRepository; //# sourceMappingURL=joint-hirer.repository.js.map