@tomei/rental
Version:
Tomei Rental Package
52 lines • 1.69 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.RentalRepository = void 0;
const general_1 = require("@tomei/general");
const rental_entity_1 = require("../../models/rental.entity");
class RentalRepository extends general_1.RepositoryBase {
constructor() {
super(rental_entity_1.RentalModel);
}
async findByPk(id, transaction) {
try {
const result = await rental_entity_1.RentalModel.findByPk(id, {
transaction: transaction,
});
return result;
}
catch (error) {
throw new Error(`An Error occured when fetching : ${error.message}`);
}
}
async delete(RentalId, dbTransaction) {
try {
const options = {
where: {
RentalId: RentalId,
},
transaction: dbTransaction,
};
await rental_entity_1.RentalModel.destroy(options);
}
catch (error) {
throw new Error(`An Error occured when delete : ${error.message}`);
}
}
async findAndCountAll(options) {
try {
let Rentals;
if (options) {
Rentals = await rental_entity_1.RentalModel.findAndCountAll(options);
}
else {
Rentals = await rental_entity_1.RentalModel.findAndCountAll();
}
return Rentals;
}
catch (error) {
throw new Error(`An Error occured when retriving : ${error.message}`);
}
}
}
exports.RentalRepository = RentalRepository;
//# sourceMappingURL=rental.repository.js.map