@travetto/model-firestore 6.0.0 → 7.0.0-rc.0
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 +6 -6
- package/src/service.ts +4 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/model-firestore",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0-rc.0",
|
|
4
4
|
"description": "Firestore backing for the travetto model module.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -25,11 +25,11 @@
|
|
|
25
25
|
"directory": "module/model-firestore"
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@google-cloud/firestore": "^7.11.
|
|
29
|
-
"@travetto/cli": "^
|
|
30
|
-
"@travetto/config": "^
|
|
31
|
-
"@travetto/model": "^
|
|
32
|
-
"@travetto/runtime": "^
|
|
28
|
+
"@google-cloud/firestore": "^7.11.6",
|
|
29
|
+
"@travetto/cli": "^7.0.0-rc.0",
|
|
30
|
+
"@travetto/config": "^7.0.0-rc.0",
|
|
31
|
+
"@travetto/model": "^7.0.0-rc.0",
|
|
32
|
+
"@travetto/runtime": "^7.0.0-rc.0"
|
|
33
33
|
},
|
|
34
34
|
"travetto": {
|
|
35
35
|
"displayName": "Firestore Model Support"
|
package/src/service.ts
CHANGED
|
@@ -3,7 +3,7 @@ import { DocumentData, FieldValue, Firestore, PartialWithFieldValue, Query } fro
|
|
|
3
3
|
import { ShutdownManager, type Class, type DeepPartial } from '@travetto/runtime';
|
|
4
4
|
import { Injectable } from '@travetto/di';
|
|
5
5
|
import {
|
|
6
|
-
ModelCrudSupport,
|
|
6
|
+
ModelCrudSupport, ModelRegistryIndex, ModelStorageSupport,
|
|
7
7
|
ModelIndexedSupport, ModelType, NotFoundError, OptionalId,
|
|
8
8
|
ModelCrudUtil, ModelIndexedUtil,
|
|
9
9
|
} from '@travetto/model';
|
|
@@ -28,7 +28,7 @@ export class FirestoreModelService implements ModelCrudSupport, ModelStorageSupp
|
|
|
28
28
|
constructor(config: FirestoreModelConfig) { this.config = config; }
|
|
29
29
|
|
|
30
30
|
#resolveTable(cls: Class): string {
|
|
31
|
-
let table =
|
|
31
|
+
let table = ModelRegistryIndex.getStoreName(cls);
|
|
32
32
|
if (this.config.namespace) {
|
|
33
33
|
table = `${this.config.namespace}_${table}`;
|
|
34
34
|
}
|
|
@@ -41,7 +41,7 @@ export class FirestoreModelService implements ModelCrudSupport, ModelStorageSupp
|
|
|
41
41
|
|
|
42
42
|
async postConstruct(): Promise<void> {
|
|
43
43
|
this.client = new Firestore(this.config);
|
|
44
|
-
ShutdownManager.onGracefulShutdown(() => this.client.terminate()
|
|
44
|
+
ShutdownManager.onGracefulShutdown(() => this.client.terminate());
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
// Storage
|
|
@@ -151,7 +151,7 @@ export class FirestoreModelService implements ModelCrudSupport, ModelStorageSupp
|
|
|
151
151
|
async * listByIndex<T extends ModelType>(cls: Class<T>, idx: string, body: DeepPartial<T>): AsyncIterable<T> {
|
|
152
152
|
ModelCrudUtil.ensureNotSubType(cls);
|
|
153
153
|
|
|
154
|
-
const cfg =
|
|
154
|
+
const cfg = ModelRegistryIndex.getIndex(cls, idx, ['sorted', 'unsorted']);
|
|
155
155
|
const { fields, sorted } = ModelIndexedUtil.computeIndexParts(cls, cfg, body, { emptySortValue: null });
|
|
156
156
|
let query = fields.reduce<Query>((q, { path, value }) =>
|
|
157
157
|
q.where(path.join('.'), '==', value), this.#getCollection(cls));
|