@unchainedshop/core-assortments 1.2.13 → 1.2.22
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.
|
@@ -5,17 +5,25 @@ export default function addMigrations(repository) {
|
|
|
5
5
|
name: 'Move _cachedProductIds cache to own collection in order to save a lot of bandwidth',
|
|
6
6
|
up: async () => {
|
|
7
7
|
const { Assortments, AssortmentProductIdCache } = await AssortmentsCollection(repository.db);
|
|
8
|
-
const assortments = await Assortments.find({}, { projection: { _id: true, _cachedProductIds: true } }).toArray();
|
|
8
|
+
const assortments = await Assortments.find({ _cachedProductIds: { $exists: true } }, { projection: { _id: true, _cachedProductIds: true } }).toArray();
|
|
9
9
|
await Promise.all(assortments.map(async (assortment) => {
|
|
10
|
-
|
|
11
|
-
_id: assortment._id,
|
|
12
|
-
}, {
|
|
10
|
+
try {
|
|
13
11
|
// eslint-disable-next-line
|
|
14
12
|
// @ts-ignore
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
13
|
+
await AssortmentProductIdCache.updateOne({
|
|
14
|
+
_id: assortment._id,
|
|
15
|
+
}, {
|
|
16
|
+
// eslint-disable-next-line
|
|
17
|
+
// @ts-ignore
|
|
18
|
+
$set: { productIds: assortment._cachedProductIds }, // eslint-disable-line
|
|
19
|
+
}, {
|
|
20
|
+
upsert: true,
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
catch (e) {
|
|
24
|
+
console.warn(e);
|
|
25
|
+
/* */
|
|
26
|
+
}
|
|
19
27
|
}));
|
|
20
28
|
await Assortments.updateMany({}, {
|
|
21
29
|
$unset: { _cachedProductIds: 1 },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"addMigrations.js","sourceRoot":"","sources":["../../src/migrations/addMigrations.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,6BAA6B,CAAC;AAEpE,MAAM,CAAC,OAAO,UAAU,aAAa,C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B,EAAE,EAAE,sBAAsB;qBAC7E,EACD;wBACE,MAAM,EAAE,IAAI;qBACb,CACF,CAAC;iBACH;gBAAC,OAAO,CAAC,EAAE;oBACV,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;oBAChB,KAAK;iBACN;YACH,CAAC,CAAC,CACH,CAAC;YAEF,MAAM,WAAW,CAAC,UAAU,CAC1B,EAAE,EACF;gBACE,MAAM,EAAE,EAAE,iBAAiB,EAAE,CAAC,EAAE;aACjC,CACF,CAAC;QACJ,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { ModuleInput } from '@unchainedshop/types/core';
|
|
2
2
|
import { AssortmentsModule, AssortmentsSettingsOptions } from '@unchainedshop/types/assortments';
|
|
3
|
-
export declare const configureAssortmentsModule: ({ db, migrationRepository, options
|
|
3
|
+
export declare const configureAssortmentsModule: ({ db, migrationRepository, options, }: ModuleInput<AssortmentsSettingsOptions>) => Promise<AssortmentsModule>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@unchainedshop/core-assortments",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.22",
|
|
4
4
|
"main": "lib/assortments-index.js",
|
|
5
5
|
"exports": {
|
|
6
6
|
".": "./lib/assortments-index.js",
|
|
@@ -30,21 +30,21 @@
|
|
|
30
30
|
},
|
|
31
31
|
"homepage": "https://github.com/unchainedshop/unchained#readme",
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@unchainedshop/events": "1.
|
|
34
|
-
"@unchainedshop/file-upload": "1.
|
|
35
|
-
"@unchainedshop/logger": "1.
|
|
36
|
-
"@unchainedshop/utils": "1.
|
|
33
|
+
"@unchainedshop/events": "^1.2.21",
|
|
34
|
+
"@unchainedshop/file-upload": "^1.2.21",
|
|
35
|
+
"@unchainedshop/logger": "^1.2.21",
|
|
36
|
+
"@unchainedshop/utils": "^1.2.21",
|
|
37
37
|
"locale": "^0.1.0",
|
|
38
38
|
"ramda": "^0.28.0",
|
|
39
|
-
"simpl-schema": "^1.12.
|
|
39
|
+
"simpl-schema": "^1.12.3"
|
|
40
40
|
},
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@types/locale": "^0.1.1",
|
|
43
|
-
"@types/node": "^16.11.
|
|
44
|
-
"@unchainedshop/types": "1.
|
|
43
|
+
"@types/node": "^16.11.57",
|
|
44
|
+
"@unchainedshop/types": "^1.2.21",
|
|
45
45
|
"cross-env": "^7.0.3",
|
|
46
|
-
"jest": "^
|
|
47
|
-
"ts-jest": "^28.0.
|
|
48
|
-
"typescript": "^4.
|
|
46
|
+
"jest": "^29.0.2",
|
|
47
|
+
"ts-jest": "^28.0.8",
|
|
48
|
+
"typescript": "^4.8.2"
|
|
49
49
|
}
|
|
50
50
|
}
|
|
@@ -8,25 +8,32 @@ export default function addMigrations(repository: MigrationRepository<Migration>
|
|
|
8
8
|
up: async () => {
|
|
9
9
|
const { Assortments, AssortmentProductIdCache } = await AssortmentsCollection(repository.db);
|
|
10
10
|
const assortments = await Assortments.find(
|
|
11
|
-
{},
|
|
11
|
+
{ _cachedProductIds: { $exists: true } },
|
|
12
12
|
{ projection: { _id: true, _cachedProductIds: true } },
|
|
13
13
|
).toArray();
|
|
14
14
|
|
|
15
15
|
await Promise.all(
|
|
16
16
|
assortments.map(async (assortment) => {
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
17
|
+
try {
|
|
18
|
+
// eslint-disable-next-line
|
|
19
|
+
// @ts-ignore
|
|
20
|
+
await AssortmentProductIdCache.updateOne(
|
|
21
|
+
{
|
|
22
|
+
_id: assortment._id as any,
|
|
23
|
+
},
|
|
24
|
+
{
|
|
25
|
+
// eslint-disable-next-line
|
|
26
|
+
// @ts-ignore
|
|
27
|
+
$set: { productIds: assortment._cachedProductIds }, // eslint-disable-line
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
upsert: true,
|
|
31
|
+
},
|
|
32
|
+
);
|
|
33
|
+
} catch (e) {
|
|
34
|
+
console.warn(e);
|
|
35
|
+
/* */
|
|
36
|
+
}
|
|
30
37
|
}),
|
|
31
38
|
);
|
|
32
39
|
|