@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 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
@@ -32,7 +32,7 @@ type SurrealCollectionConfig<T extends {
32
32
  table: TableOptions<T>;
33
33
  syncMode?: SyncMode;
34
34
  queryKey: readonly unknown[];
35
- queryClient?: QueryClient;
35
+ queryClient: QueryClient;
36
36
  useLoro?: boolean;
37
37
  onError?: (e: unknown) => void;
38
38
  };
package/dist/index.d.ts CHANGED
@@ -32,7 +32,7 @@ type SurrealCollectionConfig<T extends {
32
32
  table: TableOptions<T>;
33
33
  syncMode?: SyncMode;
34
34
  queryKey: readonly unknown[];
35
- queryClient?: QueryClient;
35
+ queryClient: QueryClient;
36
36
  useLoro?: boolean;
37
37
  onError?: (e: unknown) => void;
38
38
  };