@travetto/model-mongo 8.0.2 → 8.0.3
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.
- package/package.json +5 -5
- package/src/service.ts +8 -8
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/model-mongo",
|
|
3
|
-
"version": "8.0.
|
|
3
|
+
"version": "8.0.3",
|
|
4
4
|
"description": "Mongo backing for the travetto model module.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"database",
|
|
@@ -29,10 +29,10 @@
|
|
|
29
29
|
"access": "public"
|
|
30
30
|
},
|
|
31
31
|
"dependencies": {
|
|
32
|
-
"@travetto/config": "^8.0.
|
|
33
|
-
"@travetto/model": "^8.0.
|
|
34
|
-
"@travetto/model-indexed": "^8.0.
|
|
35
|
-
"@travetto/model-query": "^8.0.
|
|
32
|
+
"@travetto/config": "^8.0.3",
|
|
33
|
+
"@travetto/model": "^8.0.3",
|
|
34
|
+
"@travetto/model-indexed": "^8.0.3",
|
|
35
|
+
"@travetto/model-query": "^8.0.3",
|
|
36
36
|
"mongodb": "^7.6.0"
|
|
37
37
|
},
|
|
38
38
|
"peerDependencies": {
|
package/src/service.ts
CHANGED
|
@@ -641,14 +641,6 @@ export class MongoModelService
|
|
|
641
641
|
return await Promise.all(items.map(item => this.postLoad(cls, item)));
|
|
642
642
|
}
|
|
643
643
|
|
|
644
|
-
async queryCount<T extends ModelType>(cls: Class<T>, query: ModelQuery<T>): Promise<number> {
|
|
645
|
-
await QueryVerifier.verify(cls, query);
|
|
646
|
-
|
|
647
|
-
const col = await this.getStore(cls);
|
|
648
|
-
const filter = MongoUtil.extractWhereFilter(cls, query.where);
|
|
649
|
-
return col.countDocuments(filter);
|
|
650
|
-
}
|
|
651
|
-
|
|
652
644
|
async queryOne<T extends ModelType>(cls: Class<T>, query: ModelQuery<T>, failOnMany = true): Promise<T> {
|
|
653
645
|
const results = await this.query<T>(cls, { ...query, limit: failOnMany ? 2 : 1 });
|
|
654
646
|
return ModelQueryUtil.verifyGetSingleCounts<T>(cls, failOnMany, results, query.where);
|
|
@@ -785,6 +777,14 @@ export class MongoModelService
|
|
|
785
777
|
return ModelQueryAggregateUtil.resolveResult(modelClass, operation, field, rawValue);
|
|
786
778
|
}
|
|
787
779
|
|
|
780
|
+
async countByQuery<T extends ModelType>(cls: Class<T>, query: ModelQuery<T>): Promise<number> {
|
|
781
|
+
await QueryVerifier.verify(cls, query);
|
|
782
|
+
|
|
783
|
+
const col = await this.getStore(cls);
|
|
784
|
+
const filter = MongoUtil.extractWhereFilter(cls, query.where);
|
|
785
|
+
return col.countDocuments(filter);
|
|
786
|
+
}
|
|
787
|
+
|
|
788
788
|
// Suggest
|
|
789
789
|
async suggestValuesByQuery<T extends ModelType>(
|
|
790
790
|
cls: Class<T>,
|