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