@travetto/model-firestore 5.0.0-rc.9 → 5.0.1
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 +5 -4
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/model-firestore",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.1",
|
|
4
4
|
"description": "Firestore backing for the travetto model module.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -26,12 +26,12 @@
|
|
|
26
26
|
},
|
|
27
27
|
"dependencies": {
|
|
28
28
|
"@google-cloud/firestore": "^7.9.0",
|
|
29
|
-
"@travetto/
|
|
30
|
-
"@travetto/
|
|
31
|
-
"@travetto/
|
|
29
|
+
"@travetto/config": "^5.0.1",
|
|
30
|
+
"@travetto/model": "^5.0.1",
|
|
31
|
+
"@travetto/runtime": "^5.0.1"
|
|
32
32
|
},
|
|
33
33
|
"peerDependencies": {
|
|
34
|
-
"@travetto/command": "^5.0.
|
|
34
|
+
"@travetto/command": "^5.0.1"
|
|
35
35
|
},
|
|
36
36
|
"peerDependenciesMeta": {
|
|
37
37
|
"@travetto/command": {
|
package/src/service.ts
CHANGED
|
@@ -88,9 +88,9 @@ export class FirestoreModelService implements ModelCrudSupport, ModelStorageSupp
|
|
|
88
88
|
async updatePartial<T extends ModelType>(cls: Class<T>, item: Partial<T> & { id: string }, view?: string): Promise<T> {
|
|
89
89
|
ModelCrudUtil.ensureNotSubType(cls);
|
|
90
90
|
const id = item.id;
|
|
91
|
-
|
|
92
|
-
const cleaned = toSimpleObj(
|
|
93
|
-
await this.#getCollection(cls).doc(id).set(cleaned, { mergeFields: Object.keys(
|
|
91
|
+
const full = await ModelCrudUtil.naivePartialUpdate(cls, () => this.get(cls, id), item, view);
|
|
92
|
+
const cleaned = toSimpleObj(full, FieldValue.delete());
|
|
93
|
+
await this.#getCollection(cls).doc(id).set(cleaned, { mergeFields: Object.keys(full) });
|
|
94
94
|
return this.get(cls, id);
|
|
95
95
|
}
|
|
96
96
|
|
|
@@ -152,7 +152,8 @@ export class FirestoreModelService implements ModelCrudSupport, ModelStorageSupp
|
|
|
152
152
|
async * listByIndex<T extends ModelType>(cls: Class<T>, idx: string, body: DeepPartial<T>): AsyncIterable<T> {
|
|
153
153
|
ModelCrudUtil.ensureNotSubType(cls);
|
|
154
154
|
|
|
155
|
-
const
|
|
155
|
+
const cfg = ModelRegistry.getIndex(cls, idx, ['sorted', 'unsorted']);
|
|
156
|
+
const { fields, sorted } = ModelIndexedUtil.computeIndexParts(cls, cfg, body, { emptySortValue: null });
|
|
156
157
|
let query = fields.reduce<Query>((q, { path, value }) =>
|
|
157
158
|
q.where(path.join('.'), '==', value), this.#getCollection(cls));
|
|
158
159
|
|