@chevre/domain 21.9.0-alpha.7 → 21.9.0-alpha.8
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.
|
@@ -27,6 +27,15 @@ async function main() {
|
|
|
27
27
|
console.log(catalogs[0]?.id, typeof catalogs[0]?.id);
|
|
28
28
|
console.log('catalogs found', catalogs.map((catalog) => `${catalog.id} ${catalog.identifier} ${catalog.numberOfItems} ${catalog.itemListElementTypeOf}`));
|
|
29
29
|
console.log(catalogs.length);
|
|
30
|
+
|
|
31
|
+
const numCatalogs = await catalogItemRepo.count(
|
|
32
|
+
{
|
|
33
|
+
project: { id: { $eq: PROJECT_ID } },
|
|
34
|
+
itemListElement: { typeOf: { $eq: 'Offer' } }
|
|
35
|
+
// id: { $in: ['xxx'] }
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
console.log('numCatalogs:', numCatalogs);
|
|
30
39
|
}
|
|
31
40
|
|
|
32
41
|
main()
|
|
@@ -19,6 +19,7 @@ export declare class MongoRepository {
|
|
|
19
19
|
id: string;
|
|
20
20
|
dateSynced: Date;
|
|
21
21
|
}): Promise<void>;
|
|
22
|
+
count(params: Omit<factory.offerCatalog.ISearchConditions, 'limit' | 'page' | 'sort'>): Promise<number>;
|
|
22
23
|
search(params: factory.offerCatalog.ISearchConditions): Promise<IAggregatedOfferCatalog[]>;
|
|
23
24
|
findItemListElementById(params: {
|
|
24
25
|
id: string;
|
|
@@ -130,6 +130,22 @@ class MongoRepository {
|
|
|
130
130
|
.exec();
|
|
131
131
|
});
|
|
132
132
|
}
|
|
133
|
+
count(params) {
|
|
134
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
135
|
+
const conditions = MongoRepository.CREATE_MONGO_CONDITIONS(params);
|
|
136
|
+
const matchStages = conditions.map((condition) => {
|
|
137
|
+
return { $match: condition };
|
|
138
|
+
});
|
|
139
|
+
const result = yield this.offerCatalogItemModel.aggregate([
|
|
140
|
+
...matchStages,
|
|
141
|
+
{
|
|
142
|
+
$count: 'numItems'
|
|
143
|
+
}
|
|
144
|
+
])
|
|
145
|
+
.exec();
|
|
146
|
+
return (result.length > 0) ? result[0].numItems : 0;
|
|
147
|
+
});
|
|
148
|
+
}
|
|
133
149
|
search(params) {
|
|
134
150
|
var _a;
|
|
135
151
|
return __awaiter(this, void 0, void 0, function* () {
|
package/package.json
CHANGED