@unchainedshop/core-orders 4.8.13 → 4.8.15
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.
|
@@ -56,7 +56,8 @@ export declare const configureOrdersModuleQueries: ({ Orders }: {
|
|
|
56
56
|
orderId?: string;
|
|
57
57
|
orderNumber?: string;
|
|
58
58
|
}, options?: mongodb.FindOptions) => Promise<Order | null>;
|
|
59
|
-
|
|
59
|
+
findCartUserIds: () => Promise<string[]>;
|
|
60
|
+
findCartIdsToInvalidate: (maxAgeDays?: number) => Promise<string[]>;
|
|
60
61
|
findOrders: ({ limit, offset, queryString, sort, ...query }: OrderQuery & {
|
|
61
62
|
limit?: number;
|
|
62
63
|
offset?: number;
|
|
@@ -44,14 +44,16 @@ export const configureOrdersModuleQueries = ({ Orders }) => {
|
|
|
44
44
|
const selector = orderId ? generateDbFilterById(orderId) : { orderNumber };
|
|
45
45
|
return Orders.findOne(selector, options);
|
|
46
46
|
},
|
|
47
|
-
|
|
47
|
+
findCartUserIds: async () => {
|
|
48
|
+
return Orders.distinct('userId', { status: { $eq: null } });
|
|
49
|
+
},
|
|
50
|
+
findCartIdsToInvalidate: async (maxAgeDays = 30) => {
|
|
48
51
|
const ONE_DAY_IN_MILLISECONDS = 86400000;
|
|
49
52
|
const minValidDate = new Date(new Date().getTime() - maxAgeDays * ONE_DAY_IN_MILLISECONDS);
|
|
50
|
-
|
|
53
|
+
return Orders.distinct('_id', {
|
|
51
54
|
status: { $eq: null },
|
|
52
55
|
updated: { $gte: minValidDate },
|
|
53
|
-
})
|
|
54
|
-
return orders;
|
|
56
|
+
});
|
|
55
57
|
},
|
|
56
58
|
findOrders: async ({ limit, offset, queryString, sort, ...query }, options) => {
|
|
57
59
|
const defaultSortOption = [{ key: 'created', value: SortDirection.DESC }];
|
|
@@ -160,7 +160,8 @@ export declare const configureOrdersModule: ({ db, migrationRepository, options:
|
|
|
160
160
|
orderId?: string;
|
|
161
161
|
orderNumber?: string;
|
|
162
162
|
}, options?: mongodb.FindOptions) => Promise<Order | null>;
|
|
163
|
-
|
|
163
|
+
findCartUserIds: () => Promise<string[]>;
|
|
164
|
+
findCartIdsToInvalidate: (maxAgeDays?: number) => Promise<string[]>;
|
|
164
165
|
findOrders: ({ limit, offset, queryString, sort, ...query }: import("../db/OrdersCollection.ts").OrderQuery & {
|
|
165
166
|
limit?: number;
|
|
166
167
|
offset?: number;
|
package/package.json
CHANGED