@telestack/db-sdk 1.0.4 → 1.0.6
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/dist/index.js +4 -4
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -347,7 +347,7 @@ export class Query {
|
|
|
347
347
|
if (!res.ok)
|
|
348
348
|
throw new TelestackError(await res.text());
|
|
349
349
|
const data = await res.json();
|
|
350
|
-
const docs = data.map((d) => ({ id: d.id,
|
|
350
|
+
const docs = data.map((d) => ({ id: d.id, data: d.data }));
|
|
351
351
|
// Cache results locally if persistence enabled
|
|
352
352
|
if (persistence) {
|
|
353
353
|
for (const d of data) {
|
|
@@ -363,7 +363,7 @@ export class Query {
|
|
|
363
363
|
// Filter docs that belong to this collection and match filters
|
|
364
364
|
const filtered = allDocs
|
|
365
365
|
.filter(d => d.path.startsWith(this.path) && this.matches(d.data))
|
|
366
|
-
.map(d => ({ id: d.path.split('/').pop(),
|
|
366
|
+
.map(d => ({ id: d.path.split('/').pop(), data: d.data, metadata: { fromCache: true, hasPendingWrites: true } }));
|
|
367
367
|
// Sort locally if needed
|
|
368
368
|
if (this.orderByField) {
|
|
369
369
|
filtered.sort((a, b) => {
|
|
@@ -452,7 +452,7 @@ export class Query {
|
|
|
452
452
|
callback(docs);
|
|
453
453
|
}
|
|
454
454
|
else {
|
|
455
|
-
this.docsCache = [...this.docsCache.filter(d => d.id !== docId), { id: docId,
|
|
455
|
+
this.docsCache = [...this.docsCache.filter(d => d.id !== docId), { id: docId, data: event.doc.data }];
|
|
456
456
|
changed = true;
|
|
457
457
|
}
|
|
458
458
|
}
|
|
@@ -466,7 +466,7 @@ export class Query {
|
|
|
466
466
|
callback(docs);
|
|
467
467
|
}
|
|
468
468
|
else if (matches) {
|
|
469
|
-
this.docsCache = this.docsCache.map(d => d.id === docId ? { ...d, ...docData } : d);
|
|
469
|
+
this.docsCache = this.docsCache.map(d => d.id === docId ? { ...d, data: { ...d.data, ...docData } } : d);
|
|
470
470
|
changed = true;
|
|
471
471
|
}
|
|
472
472
|
else {
|