tanstack-db-pglite 1.3.6 → 1.3.7
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/README.md +2 -6
- package/dist/drizzle.d.ts +1 -1
- package/dist/drizzle.js +2 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -38,14 +38,12 @@ export const chatsCollection = createCollection(drizzleCollectionOptions({
|
|
|
38
38
|
prepare: async () => {
|
|
39
39
|
await waitForMigrations()
|
|
40
40
|
},
|
|
41
|
-
sync: async ({
|
|
41
|
+
sync: async ({ write, markReady }) => {
|
|
42
42
|
const eventSource = new EventSource('/api/chats/sync')
|
|
43
43
|
|
|
44
44
|
eventSource.onmessage = (event) => {
|
|
45
45
|
const item = JSON.parse(event.data)
|
|
46
|
-
begin()
|
|
47
46
|
write(item)
|
|
48
|
-
commit()
|
|
49
47
|
}
|
|
50
48
|
|
|
51
49
|
eventSource.addEventListener('ready', () => markReady())
|
|
@@ -96,14 +94,12 @@ export const chatsCollection = createCollection(sqlCollectionOptions({
|
|
|
96
94
|
)
|
|
97
95
|
`)
|
|
98
96
|
},
|
|
99
|
-
sync: async ({
|
|
97
|
+
sync: async ({ write, markReady }) => {
|
|
100
98
|
const eventSource = new EventSource('/api/chats/sync')
|
|
101
99
|
|
|
102
100
|
eventSource.onmessage = (event) => {
|
|
103
101
|
const item = JSON.parse(event.data)
|
|
104
|
-
begin()
|
|
105
102
|
write(item)
|
|
106
|
-
commit()
|
|
107
103
|
}
|
|
108
104
|
|
|
109
105
|
eventSource.addEventListener('ready', () => markReady())
|
package/dist/drizzle.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export declare function drizzleCollectionOptions<Table extends PgTable>({ startS
|
|
|
19
19
|
table: Table;
|
|
20
20
|
primaryColumn: IndexColumn;
|
|
21
21
|
rowUpdateMode?: 'partial' | 'full';
|
|
22
|
-
sync?: (params: SyncParams<Table>) => Promise<(() => void) | void>;
|
|
22
|
+
sync?: (params: Pick<SyncParams<Table>, 'write' | 'collection' | 'markReady' | 'metadata'>) => Promise<(() => void) | void>;
|
|
23
23
|
prepare?: () => Promise<unknown> | unknown;
|
|
24
24
|
onInsert?: (params: InsertMutationFnParams<Table['$inferSelect'], string>) => Promise<void>;
|
|
25
25
|
onUpdate?: (params: UpdateMutationFnParams<Table['$inferSelect'], string>) => Promise<void>;
|
package/dist/drizzle.js
CHANGED
|
@@ -89,13 +89,12 @@ export function drizzleCollectionOptions({ startSync = true, ...config }) {
|
|
|
89
89
|
const key = 'key' in message ? message.key : params.collection.getKeyFromItem(message.value);
|
|
90
90
|
await onDrizzleDelete([key]);
|
|
91
91
|
}
|
|
92
|
+
params.begin();
|
|
92
93
|
params.write(message);
|
|
94
|
+
params.commit();
|
|
93
95
|
},
|
|
94
96
|
collection: params.collection,
|
|
95
97
|
markReady: params.markReady,
|
|
96
|
-
begin: params.begin,
|
|
97
|
-
commit: params.commit,
|
|
98
|
-
truncate: params.truncate,
|
|
99
98
|
...(params.metadata && { metadata: params.metadata }),
|
|
100
99
|
});
|
|
101
100
|
};
|