pop theme

This commit is contained in:
morteza-mortezai
2025-12-13 16:37:16 +03:30
parent a979d77ca5
commit 6f49c3fc8f
2 changed files with 29 additions and 9 deletions
+5 -1
View File
@@ -82,13 +82,17 @@ class SaleFormatDTO {
}
//#################################
export class ThemeDTO {
@Expose()
title: string;
}
export class ThemeValueDTO {
@Expose()
_id: string;
@Expose()
theme: string;
theme: ThemeDTO;
@Expose()
name?: string;
@@ -86,15 +86,36 @@ export class ProductVariantRepository extends BaseRepository<IProductVariant> {
{
$unwind: "$category",
},
{
$lookup: {
from: "themeValues",
from: "themevalues",
localField: "themeValue",
foreignField: "_id",
as: "themeValue",
},
},
{
$unwind: {
path: "$themeValue",
preserveNullAndEmptyArrays: true,
},
},
{
$lookup: {
from: "themes",
localField: "themeValue.theme",
foreignField: "_id",
as: "theme_doc",
},
},
{
$addFields: {
"themeValue.theme": { $arrayElemAt: ["$theme_doc", 0] },
},
},
{
$project: { theme_doc: 0 }, // drop the temporary array
},
{
$lookup: {
from: "shipments",
@@ -103,12 +124,7 @@ export class ProductVariantRepository extends BaseRepository<IProductVariant> {
as: "shipmentMethod",
},
},
{
$unwind: {
path: "$themeValue",
preserveNullAndEmptyArrays: true,
},
},
{
$addFields: {