feat: select all field for the brand
This commit is contained in:
@@ -76,11 +76,11 @@ class BrandRepository extends BaseRepository<IBrand> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async findWithName(name: string) {
|
async findWithName(name: string) {
|
||||||
return this.model.findOne({ title_en: name }, { _id: 1, title_en: 1, title_fa: 1, status: 1, image: 1, category: 1 });
|
return this.model.findOne({ title_en: name, deleted: false });
|
||||||
}
|
}
|
||||||
|
|
||||||
async getPendingBrandsCount() {
|
async getPendingBrandsCount() {
|
||||||
return this.model.countDocuments({ status: StatusEnum.Pending });
|
return this.model.countDocuments({ status: StatusEnum.Pending, deleted: false });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
function createBrandRepository(): BrandRepository {
|
function createBrandRepository(): BrandRepository {
|
||||||
|
|||||||
@@ -2471,11 +2471,11 @@ export class ProductRepository extends BaseRepository<IProduct> {
|
|||||||
"variants.market_status": ProductMarketStatus.Marketable,
|
"variants.market_status": ProductMarketStatus.Marketable,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
// {
|
||||||
$match: {
|
// $match: {
|
||||||
variants: { $gt: [{ $size: "$variants" }, 0] }, // Ensure variants array has elements
|
// variants: { $gt: [{ $size: "$variants" }, 0] }, // Ensure variants array has elements
|
||||||
},
|
// },
|
||||||
},
|
// },
|
||||||
{
|
{
|
||||||
$lookup: {
|
$lookup: {
|
||||||
from: "categories",
|
from: "categories",
|
||||||
@@ -2613,7 +2613,7 @@ export class ProductRepository extends BaseRepository<IProduct> {
|
|||||||
docs: docs[0]?.data || [],
|
docs: docs[0]?.data || [],
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
//**************************************************************
|
||||||
async getProductSpecification(productIds: string[] | string) {
|
async getProductSpecification(productIds: string[] | string) {
|
||||||
const matchQuery: { [k: string]: unknown } = {
|
const matchQuery: { [k: string]: unknown } = {
|
||||||
deleted: false,
|
deleted: false,
|
||||||
|
|||||||
@@ -1012,22 +1012,17 @@ class ProductService {
|
|||||||
//**************************************************************
|
//**************************************************************
|
||||||
//**************************************************************
|
//**************************************************************
|
||||||
async searchForCompareProductsS(queries: CompareSearchQueries) {
|
async searchForCompareProductsS(queries: CompareSearchQueries) {
|
||||||
const product = await this.validateProduct(+queries.productId);
|
const product = await this.validateProduct(queries.productId);
|
||||||
const { docs, count } = await this.productRepo.getProductsForCompareSearch(product.category.toString(), queries);
|
const { docs, count } = await this.productRepo.getProductsForCompareSearch(product.category.toString(), queries);
|
||||||
const products = docs.map((doc: IProduct) => ProductDTO.transformProduct(doc));
|
const products = docs.map((doc: IProduct) => ProductDTO.transformProduct(doc));
|
||||||
return {
|
return { count, products };
|
||||||
count,
|
|
||||||
products,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
//**************************************************************
|
//**************************************************************
|
||||||
//**************************************************************
|
//**************************************************************
|
||||||
async compareProducts(productIds: string[] | string) {
|
async compareProducts(productIds: string[] | string) {
|
||||||
const docs = await this.productRepo.getProductSpecification(productIds);
|
const docs = await this.productRepo.getProductSpecification(productIds);
|
||||||
const products = docs.map((doc: IProduct) => ProductDTO.transformProduct(doc));
|
const products = docs.map((doc: IProduct) => ProductDTO.transformProduct(doc));
|
||||||
return {
|
return { products };
|
||||||
products,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//###############################################################
|
//###############################################################
|
||||||
|
|||||||
Reference in New Issue
Block a user