@foretag/tanstack-db-surrealdb 0.1.16 → 0.1.17
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 +9 -9
- package/dist/index.mjs +10 -10
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -81,7 +81,7 @@ function manageTable(db, useLoro, { name, ...args }) {
|
|
|
81
81
|
let killed = false;
|
|
82
82
|
let live;
|
|
83
83
|
const on = ({ action, value }) => {
|
|
84
|
-
console.debug("[
|
|
84
|
+
console.debug("[Surreal Live]", name, action, value);
|
|
85
85
|
if (action === "KILLED") return;
|
|
86
86
|
if (action === "CREATE") cb({ type: "insert", row: value });
|
|
87
87
|
else if (action === "UPDATE")
|
|
@@ -289,6 +289,11 @@ function surrealCollectionOptions({
|
|
|
289
289
|
commit,
|
|
290
290
|
markReady
|
|
291
291
|
}) => {
|
|
292
|
+
if (!db.isFeatureSupported(import_surrealdb2.Features.LiveQueries)) {
|
|
293
|
+
markReady();
|
|
294
|
+
return () => {
|
|
295
|
+
};
|
|
296
|
+
}
|
|
292
297
|
let offLive = null;
|
|
293
298
|
const makeTombstone = (id2) => ({
|
|
294
299
|
id: new import_surrealdb2.RecordId(config.table.name, id2).toString(),
|
|
@@ -299,11 +304,8 @@ function surrealCollectionOptions({
|
|
|
299
304
|
try {
|
|
300
305
|
const serverRows = await table.listAll();
|
|
301
306
|
begin();
|
|
302
|
-
if (useLoro)
|
|
303
|
-
|
|
304
|
-
} else {
|
|
305
|
-
diffAndEmit(serverRows, write);
|
|
306
|
-
}
|
|
307
|
+
if (useLoro) reconcileBoot(serverRows, write);
|
|
308
|
+
else diffAndEmit(serverRows, write);
|
|
307
309
|
commit();
|
|
308
310
|
markReady();
|
|
309
311
|
await flushPushQueue();
|
|
@@ -386,9 +388,7 @@ function surrealCollectionOptions({
|
|
|
386
388
|
for (const m of p.transaction.mutations) {
|
|
387
389
|
if (m.type !== "delete") continue;
|
|
388
390
|
const id2 = m.key;
|
|
389
|
-
if (useLoro)
|
|
390
|
-
loroRemove(keyOf(id2));
|
|
391
|
-
}
|
|
391
|
+
if (useLoro) loroRemove(keyOf(id2));
|
|
392
392
|
await table.softDelete(new import_surrealdb2.RecordId(config.table.name, keyOf(id2)));
|
|
393
393
|
}
|
|
394
394
|
return resultRows;
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
2
|
import { LoroDoc } from "loro-crdt";
|
|
3
|
-
import { RecordId } from "surrealdb";
|
|
3
|
+
import { Features as Features2, RecordId } from "surrealdb";
|
|
4
4
|
|
|
5
5
|
// src/table.ts
|
|
6
6
|
import {
|
|
@@ -63,7 +63,7 @@ function manageTable(db, useLoro, { name, ...args }) {
|
|
|
63
63
|
let killed = false;
|
|
64
64
|
let live;
|
|
65
65
|
const on = ({ action, value }) => {
|
|
66
|
-
console.debug("[
|
|
66
|
+
console.debug("[Surreal Live]", name, action, value);
|
|
67
67
|
if (action === "KILLED") return;
|
|
68
68
|
if (action === "CREATE") cb({ type: "insert", row: value });
|
|
69
69
|
else if (action === "UPDATE")
|
|
@@ -271,6 +271,11 @@ function surrealCollectionOptions({
|
|
|
271
271
|
commit,
|
|
272
272
|
markReady
|
|
273
273
|
}) => {
|
|
274
|
+
if (!db.isFeatureSupported(Features2.LiveQueries)) {
|
|
275
|
+
markReady();
|
|
276
|
+
return () => {
|
|
277
|
+
};
|
|
278
|
+
}
|
|
274
279
|
let offLive = null;
|
|
275
280
|
const makeTombstone = (id2) => ({
|
|
276
281
|
id: new RecordId(config.table.name, id2).toString(),
|
|
@@ -281,11 +286,8 @@ function surrealCollectionOptions({
|
|
|
281
286
|
try {
|
|
282
287
|
const serverRows = await table.listAll();
|
|
283
288
|
begin();
|
|
284
|
-
if (useLoro)
|
|
285
|
-
|
|
286
|
-
} else {
|
|
287
|
-
diffAndEmit(serverRows, write);
|
|
288
|
-
}
|
|
289
|
+
if (useLoro) reconcileBoot(serverRows, write);
|
|
290
|
+
else diffAndEmit(serverRows, write);
|
|
289
291
|
commit();
|
|
290
292
|
markReady();
|
|
291
293
|
await flushPushQueue();
|
|
@@ -368,9 +370,7 @@ function surrealCollectionOptions({
|
|
|
368
370
|
for (const m of p.transaction.mutations) {
|
|
369
371
|
if (m.type !== "delete") continue;
|
|
370
372
|
const id2 = m.key;
|
|
371
|
-
if (useLoro)
|
|
372
|
-
loroRemove(keyOf(id2));
|
|
373
|
-
}
|
|
373
|
+
if (useLoro) loroRemove(keyOf(id2));
|
|
374
374
|
await table.softDelete(new RecordId(config.table.name, keyOf(id2)));
|
|
375
375
|
}
|
|
376
376
|
return resultRows;
|
package/package.json
CHANGED