@telestack/db-sdk 1.0.3 → 1.0.5

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.
Files changed (2) hide show
  1. package/dist/index.js +6 -3
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -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, ...event.doc.data }];
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 {
@@ -501,7 +501,10 @@ export class Query {
501
501
  if (!centrifuge)
502
502
  return () => { };
503
503
  const channel = `collection:${this.path.replace(/\//g, '_')}`;
504
- const sub = centrifuge.newSubscription(channel);
504
+ let sub = centrifuge.getSubscription(channel);
505
+ if (!sub) {
506
+ sub = centrifuge.newSubscription(channel);
507
+ }
505
508
  sub.on('join', (ctx) => {
506
509
  callback({ action: 'join', user: ctx.info.user, clientId: ctx.info.client });
507
510
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@telestack/db-sdk",
3
- "version": "1.0.3",
3
+ "version": "1.0.5",
4
4
  "description": "Fluent, real-time SDK for Telestack DB",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",