UNPKG

@tomei/product

Version:

NestJS package for product module

56 lines 2.15 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.ProductVariantWithInventoryRepository = void 0; const general_1 = require("@tomei/general"); const product_variant_with_inventory_entity_1 = require("../../entities/product-variant-with-inventory.entity"); class ProductVariantWithInventoryRepository extends general_1.RepositoryBase { constructor() { super(product_variant_with_inventory_entity_1.ProductVariantWithInventoryModel); } async findByPk(variantId, transaction) { try { const options = { where: { VariantId: variantId, }, transaction, }; const result = await product_variant_with_inventory_entity_1.ProductVariantWithInventoryModel.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_with_inventory_entity_1.ProductVariantWithInventoryModel.destroy(options); } catch (error) { throw new Error(`An Error occured when delete : ${error.message}`); } } async findAndCountAll(options) { try { let vwi; if (options) { vwi = await product_variant_with_inventory_entity_1.ProductVariantWithInventoryModel.findAndCountAll(options); } else { vwi = await product_variant_with_inventory_entity_1.ProductVariantWithInventoryModel.findAndCountAll(); } return vwi; } catch (error) { throw new Error(`An Error occured when retriving : ${error.message}`); } } } exports.ProductVariantWithInventoryRepository = ProductVariantWithInventoryRepository; //# sourceMappingURL=variant-product-with-inventory.repository.js.map