tanstack-db-pglite 1.2.2 → 1.2.4
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/drizzle.js +13 -17
- package/dist/sql.js +13 -17
- package/package.json +2 -3
package/dist/drizzle.js
CHANGED
|
@@ -72,23 +72,19 @@ export function drizzleCollectionOptions({ startSync = true, ...config }) {
|
|
|
72
72
|
previousResolvers.resolve({ continue: true });
|
|
73
73
|
await config.sync({
|
|
74
74
|
write: async (message) => {
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
if (message.type === 'insert') {
|
|
78
|
-
await onDrizzleInsert([message.value]);
|
|
79
|
-
}
|
|
80
|
-
else if (message.type === 'update') {
|
|
81
|
-
await onDrizzleUpdate(params.collection.getKeyFromItem(message.value), message.value);
|
|
82
|
-
}
|
|
83
|
-
else if (message.type === 'delete') {
|
|
84
|
-
const key = 'key' in message ? message.key : params.collection.getKeyFromItem(message.value);
|
|
85
|
-
await onDrizzleDelete([key]);
|
|
86
|
-
}
|
|
87
|
-
params.write(message);
|
|
75
|
+
if (message.type === 'insert') {
|
|
76
|
+
await onDrizzleInsert([message.value]);
|
|
88
77
|
}
|
|
89
|
-
|
|
90
|
-
params.
|
|
78
|
+
else if (message.type === 'update') {
|
|
79
|
+
await onDrizzleUpdate(params.collection.getKeyFromItem(message.value), message.value);
|
|
91
80
|
}
|
|
81
|
+
else if (message.type === 'delete') {
|
|
82
|
+
const key = 'key' in message ? message.key : params.collection.getKeyFromItem(message.value);
|
|
83
|
+
await onDrizzleDelete([key]);
|
|
84
|
+
}
|
|
85
|
+
params.begin();
|
|
86
|
+
params.write(message);
|
|
87
|
+
params.commit();
|
|
92
88
|
},
|
|
93
89
|
collection: params.collection,
|
|
94
90
|
});
|
|
@@ -105,9 +101,9 @@ export function drizzleCollectionOptions({ startSync = true, ...config }) {
|
|
|
105
101
|
(async () => {
|
|
106
102
|
try {
|
|
107
103
|
await config.prepare?.();
|
|
108
|
-
params.begin();
|
|
109
104
|
// @ts-expect-error drizzle types
|
|
110
105
|
const dbs = await config.db.select().from(config.table);
|
|
106
|
+
params.begin();
|
|
111
107
|
dbs.forEach((db) => {
|
|
112
108
|
params.write({ type: 'insert', value: db });
|
|
113
109
|
});
|
|
@@ -161,7 +157,7 @@ export function drizzleCollectionOptions({ startSync = true, ...config }) {
|
|
|
161
157
|
}
|
|
162
158
|
const params = await syncParams;
|
|
163
159
|
await params.collection.stateWhenReady();
|
|
164
|
-
sync();
|
|
160
|
+
await sync();
|
|
165
161
|
},
|
|
166
162
|
waitForSync,
|
|
167
163
|
},
|
package/dist/sql.js
CHANGED
|
@@ -59,23 +59,19 @@ export function sqlCollectionOptions({ startSync = true, ...config }) {
|
|
|
59
59
|
previousResolvers.resolve({ continue: true });
|
|
60
60
|
await config.sync({
|
|
61
61
|
write: async (p) => {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
if (p.type === 'insert') {
|
|
65
|
-
await runInsert(config.db, [p.value]);
|
|
66
|
-
}
|
|
67
|
-
else if (p.type === 'update') {
|
|
68
|
-
await runUpdate(config.db, params.collection.getKeyFromItem(p.value), p.value);
|
|
69
|
-
}
|
|
70
|
-
else if (p.type === 'delete') {
|
|
71
|
-
const key = 'key' in p ? p.key : params.collection.getKeyFromItem(p.value);
|
|
72
|
-
await runDelete(config.db, [key]);
|
|
73
|
-
}
|
|
74
|
-
params.write(p);
|
|
62
|
+
if (p.type === 'insert') {
|
|
63
|
+
await runInsert(config.db, [p.value]);
|
|
75
64
|
}
|
|
76
|
-
|
|
77
|
-
params.
|
|
65
|
+
else if (p.type === 'update') {
|
|
66
|
+
await runUpdate(config.db, params.collection.getKeyFromItem(p.value), p.value);
|
|
78
67
|
}
|
|
68
|
+
else if (p.type === 'delete') {
|
|
69
|
+
const key = 'key' in p ? p.key : params.collection.getKeyFromItem(p.value);
|
|
70
|
+
await runDelete(config.db, [key]);
|
|
71
|
+
}
|
|
72
|
+
params.begin();
|
|
73
|
+
params.write(p);
|
|
74
|
+
params.commit();
|
|
79
75
|
},
|
|
80
76
|
collection: params.collection,
|
|
81
77
|
});
|
|
@@ -92,8 +88,8 @@ export function sqlCollectionOptions({ startSync = true, ...config }) {
|
|
|
92
88
|
(async () => {
|
|
93
89
|
try {
|
|
94
90
|
await config.prepare?.();
|
|
95
|
-
params.begin();
|
|
96
91
|
const rows = await runSelect(config.db);
|
|
92
|
+
params.begin();
|
|
97
93
|
rows.forEach((row) => {
|
|
98
94
|
params.write({ type: 'insert', value: row });
|
|
99
95
|
});
|
|
@@ -144,7 +140,7 @@ export function sqlCollectionOptions({ startSync = true, ...config }) {
|
|
|
144
140
|
}
|
|
145
141
|
const params = await syncParams;
|
|
146
142
|
await params.collection.stateWhenReady();
|
|
147
|
-
sync();
|
|
143
|
+
await sync();
|
|
148
144
|
},
|
|
149
145
|
waitForSync,
|
|
150
146
|
},
|
package/package.json
CHANGED
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tanstack-db-pglite",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.4",
|
|
4
4
|
"packageManager": "pnpm@10.32.1",
|
|
5
5
|
"description": "",
|
|
6
6
|
"author": "Valerii Strilets",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"repository": {
|
|
9
9
|
"type": "git",
|
|
10
|
-
"url": "git+https://github.com/letstri/tanstack-db-pglite.git"
|
|
11
|
-
"directory": "tanstack-db-pglite"
|
|
10
|
+
"url": "git+https://github.com/letstri/tanstack-db-pglite.git"
|
|
12
11
|
},
|
|
13
12
|
"keywords": [
|
|
14
13
|
"tanstack",
|