@unchainedshop/core-assortments 4.8.22 → 4.8.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -37,18 +37,18 @@ export const AssortmentsCollection = async (db) => {
|
|
|
37
37
|
{ index: { locale: 1, assortmentId: 1 } },
|
|
38
38
|
]);
|
|
39
39
|
await buildDbIndexes(AssortmentProducts, [
|
|
40
|
-
{ index: { assortmentId: 1 } },
|
|
40
|
+
{ index: { assortmentId: 1, productId: 1 } },
|
|
41
41
|
{ index: { productId: 1 } },
|
|
42
42
|
{ index: { tags: 1 } },
|
|
43
43
|
{ index: { assortmentId: 1, sortKey: 1 } },
|
|
44
|
-
]);
|
|
44
|
+
], { rebuild: false });
|
|
45
45
|
await buildDbIndexes(AssortmentLinks, [
|
|
46
46
|
{ index: { parentAssortmentId: 1 } },
|
|
47
|
-
{ index: { childAssortmentId: 1 } },
|
|
47
|
+
{ index: { childAssortmentId: 1, sortKey: 1, parentAssortmentId: 1 } },
|
|
48
48
|
{ index: { tags: 1 } },
|
|
49
49
|
{ index: { parentAssortmentId: 1, sortKey: 1 } },
|
|
50
50
|
{ index: { childAssortmentId: 1, parentAssortmentId: 1, sortKey: 1 } },
|
|
51
|
-
]);
|
|
51
|
+
], { rebuild: false });
|
|
52
52
|
await buildDbIndexes(AssortmentFilters, [
|
|
53
53
|
{ index: { assortmentId: 1 } },
|
|
54
54
|
{ index: { filterId: 1 } },
|
|
@@ -9,11 +9,13 @@ export declare const configureAssortmentLinksModule: ({ AssortmentLinks, invalid
|
|
|
9
9
|
parentAssortmentId?: string;
|
|
10
10
|
childAssortmentId?: string;
|
|
11
11
|
}) => Promise<mongodb.WithId<AssortmentLink> | null>;
|
|
12
|
-
findLinks: ({ assortmentId, assortmentIds, parentAssortmentId, parentAssortmentIds, }: {
|
|
12
|
+
findLinks: ({ assortmentId, assortmentIds, parentAssortmentId, parentAssortmentIds, childAssortmentId, childAssortmentIds, }: {
|
|
13
13
|
assortmentId?: string;
|
|
14
14
|
assortmentIds?: string[];
|
|
15
15
|
parentAssortmentId?: string;
|
|
16
16
|
parentAssortmentIds?: string[];
|
|
17
|
+
childAssortmentId?: string;
|
|
18
|
+
childAssortmentIds?: string[];
|
|
17
19
|
}, options?: mongodb.FindOptions) => Promise<AssortmentLink[]>;
|
|
18
20
|
create: (doc: Omit<AssortmentLink, "_id" | "created" | "sortKey"> & Pick<Partial<AssortmentLink>, "_id" | "created" | "sortKey">, options?: {
|
|
19
21
|
skipInvalidation?: boolean;
|
|
@@ -15,17 +15,21 @@ export const configureAssortmentLinksModule = ({ AssortmentLinks, invalidateCach
|
|
|
15
15
|
? generateDbFilterById(assortmentLinkId)
|
|
16
16
|
: { parentAssortmentId, childAssortmentId }, {});
|
|
17
17
|
},
|
|
18
|
-
findLinks: async ({ assortmentId, assortmentIds, parentAssortmentId, parentAssortmentIds, }, options) => {
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
};
|
|
18
|
+
findLinks: async ({ assortmentId, assortmentIds, parentAssortmentId, parentAssortmentIds, childAssortmentId, childAssortmentIds, }, options) => {
|
|
19
|
+
const selectors = [];
|
|
20
|
+
const parentIds = parentAssortmentId || (parentAssortmentIds && { $in: parentAssortmentIds });
|
|
21
|
+
const childIds = childAssortmentId || (childAssortmentIds && { $in: childAssortmentIds });
|
|
22
|
+
const bidirectionalIds = assortmentId || (assortmentIds && { $in: assortmentIds });
|
|
23
|
+
if (parentIds)
|
|
24
|
+
selectors.push({ parentAssortmentId: parentIds });
|
|
25
|
+
if (childIds)
|
|
26
|
+
selectors.push({ childAssortmentId: childIds });
|
|
27
|
+
if (bidirectionalIds) {
|
|
28
|
+
selectors.push({ parentAssortmentId: bidirectionalIds }, { childAssortmentId: bidirectionalIds });
|
|
29
|
+
}
|
|
30
|
+
if (!selectors.length)
|
|
31
|
+
return [];
|
|
32
|
+
const selector = selectors.length > 1 ? { $or: selectors } : selectors[0];
|
|
29
33
|
const links = AssortmentLinks.find(selector, options || {
|
|
30
34
|
sort: { sortKey: 1 },
|
|
31
35
|
});
|
|
@@ -133,11 +133,13 @@ export declare const configureAssortmentsModule: (moduleInput: ModuleInput<Assor
|
|
|
133
133
|
parentAssortmentId?: string;
|
|
134
134
|
childAssortmentId?: string;
|
|
135
135
|
}) => Promise<mongodb.WithId<AssortmentLink> | null>;
|
|
136
|
-
findLinks: ({ assortmentId, assortmentIds, parentAssortmentId, parentAssortmentIds, }: {
|
|
136
|
+
findLinks: ({ assortmentId, assortmentIds, parentAssortmentId, parentAssortmentIds, childAssortmentId, childAssortmentIds, }: {
|
|
137
137
|
assortmentId?: string;
|
|
138
138
|
assortmentIds?: string[];
|
|
139
139
|
parentAssortmentId?: string;
|
|
140
140
|
parentAssortmentIds?: string[];
|
|
141
|
+
childAssortmentId?: string;
|
|
142
|
+
childAssortmentIds?: string[];
|
|
141
143
|
}, options?: mongodb.FindOptions) => Promise<AssortmentLink[]>;
|
|
142
144
|
create: (doc: Omit<AssortmentLink, "_id" | "created" | "sortKey"> & Pick<Partial<AssortmentLink>, "_id" | "created" | "sortKey">, options?: {
|
|
143
145
|
skipInvalidation?: boolean;
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unchainedshop/core-assortments",
|
|
3
3
|
"description": "Assortment and category management module for the Unchained Engine",
|
|
4
|
-
"version": "4.8.
|
|
4
|
+
"version": "4.8.24",
|
|
5
5
|
"main": "lib/assortments-index.js",
|
|
6
6
|
"types": "lib/assortments-index.d.ts",
|
|
7
7
|
"type": "module",
|