@foretag/tanstack-db-surrealdb 0.3.1 → 0.3.3
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 +6 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +46 -1841
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +35 -1811
- package/dist/index.mjs.map +1 -0
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -20,15 +20,18 @@ bun install @foretag/tanstack-db-surrealdb
|
|
|
20
20
|
## Usage
|
|
21
21
|
```ts
|
|
22
22
|
// db.ts
|
|
23
|
+
import { QueryClient } from '@tanstack/svelte-query'; // Can also use '@tanstack/react-query' etc.
|
|
23
24
|
import { Surreal } from 'surrealdb';
|
|
24
25
|
|
|
25
26
|
export const db = new Surreal();
|
|
26
27
|
await db.connect('ws://localhost:8000/rpc');
|
|
27
28
|
await db.use({ ns: 'ns', db: 'db' });
|
|
28
29
|
|
|
30
|
+
export const queryClient = new QueryClient();
|
|
31
|
+
|
|
29
32
|
// collections/products.ts
|
|
30
33
|
import { eq } from 'surrealdb';
|
|
31
|
-
import { db } from '../db';
|
|
34
|
+
import { db, queryClient } from '../db';
|
|
32
35
|
import { createCollection } from '@tanstack/db';
|
|
33
36
|
import { surrealCollectionOptions } from '@foretag/tanstack-db-surrealdb';
|
|
34
37
|
|
|
@@ -42,6 +45,8 @@ type Product = {
|
|
|
42
45
|
export const products = createCollection(
|
|
43
46
|
surrealCollection<Product>({
|
|
44
47
|
db,
|
|
48
|
+
queryKey: ['products'],
|
|
49
|
+
queryClient,
|
|
45
50
|
useLoro: true, // Optional if you need CRDTs
|
|
46
51
|
table: {
|
|
47
52
|
name: 'products',
|
package/dist/index.d.mts
CHANGED
package/dist/index.d.ts
CHANGED