@tomei/product
Version:
NestJS package for product module
56 lines • 1.89 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.ProductBrandRepository = void 0;
const general_1 = require("@tomei/general");
const product_brand_entity_1 = require("../../entities/product-brand.entity");
class ProductBrandRepository extends general_1.RepositoryBase {
constructor() {
super(product_brand_entity_1.ProductBrandModel);
}
async findByPk(brand, transaction) {
try {
const options = {
where: {
Brand: brand,
},
transaction: transaction,
};
const result = await product_brand_entity_1.ProductBrandModel.findOne(options);
return result;
}
catch (error) {
throw new Error(`An Error occured when fetching : ${error.message}`);
}
}
async delete(brand, dbTransaction) {
try {
const options = {
where: {
Brand: brand,
},
transaction: dbTransaction,
};
await product_brand_entity_1.ProductBrandModel.destroy(options);
}
catch (error) {
throw new Error(`An Error occured when delete : ${error.message}`);
}
}
async findAndCountAll(options) {
try {
let tags;
if (options) {
tags = await product_brand_entity_1.ProductBrandModel.findAndCountAll(options);
}
else {
tags = await product_brand_entity_1.ProductBrandModel.findAndCountAll();
}
return tags;
}
catch (error) {
throw new Error(`An Error occured when retriving : ${error.message}`);
}
}
}
exports.ProductBrandRepository = ProductBrandRepository;
//# sourceMappingURL=brand-product.repository.js.map