@goatlab/fluent-pouchdb 0.7.14 → 0.8.1

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
@@ -1,6 +1,6 @@
1
1
  # @goatlab/fluent-pouchdb
2
2
 
3
- PouchDB connector for the Goat Fluent query interface. Enables you to use PouchDB with the same unified API as other Fluent database connectors.
3
+ PouchDB connector for the Goat Fluent query interface. Enables offline-first applications with automatic synchronization capabilities.
4
4
 
5
5
  ## Installation
6
6
 
@@ -16,25 +16,41 @@ pnpm add @goatlab/fluent-pouchdb
16
16
 
17
17
  ```typescript
18
18
  import { PouchDBConnector, PouchDB } from '@goatlab/fluent-pouchdb'
19
+ import { f } from '@goatlab/fluent'
19
20
  import { z } from 'zod'
20
21
 
21
- // Define your schema
22
+ // Define entity
23
+ @f.entity('users')
24
+ class UserEntity {
25
+ @f.id()
26
+ id?: string
27
+
28
+ @f.property({ required: true })
29
+ name: string
30
+
31
+ @f.property({ required: true })
32
+ email: string
33
+
34
+ @f.created()
35
+ createdAt?: Date
36
+ }
37
+
38
+ // Define schema
22
39
  const UserSchema = z.object({
23
- id: z.string(),
40
+ id: z.string().optional(),
24
41
  name: z.string(),
25
42
  email: z.string().email(),
26
- created: z.date().optional()
43
+ createdAt: z.date().optional()
27
44
  })
28
45
 
29
46
  // Create PouchDB instance
30
- const db = new PouchDB('users', { adapter: 'memory' }) // or use 'leveldb' for persistence
47
+ const db = new PouchDB('users')
31
48
 
32
49
  // Initialize connector
33
50
  const users = new PouchDBConnector({
34
- entity: UserEntity, // Your entity class with decorators
51
+ entity: UserEntity,
35
52
  dataSource: db,
36
- inputSchema: UserSchema,
37
- outputSchema: UserSchema // optional, defaults to inputSchema
53
+ inputSchema: UserSchema
38
54
  })
39
55
 
40
56
  // Use Fluent API
@@ -43,20 +59,34 @@ const user = await users.insert({
43
59
  email: 'john@example.com'
44
60
  })
45
61
 
62
+ // Query data
46
63
  const found = await users.findMany({
47
64
  where: { email: { equals: 'john@example.com' } },
48
- orderBy: [{ created: 'desc' }],
65
+ orderBy: [{ createdAt: 'desc' }],
49
66
  limit: 10
50
67
  })
68
+
69
+ // Sync with CouchDB
70
+ db.sync('http://localhost:5984/users', {
71
+ live: true,
72
+ retry: true
73
+ })
51
74
  ```
52
75
 
53
76
  ## Key Features
54
77
 
78
+ - **Offline-First** - Works without internet connection
79
+ - **Automatic Sync** - Bidirectional replication with CouchDB
55
80
  - **Unified Fluent API** - Same query interface as other Fluent connectors
56
- - **Full CRUD operations** - insert, update, replace, delete with validation
57
- - **Advanced querying** - Complex where clauses with AND/OR logic
58
- - **Schema validation** - Input/output validation with Zod schemas
59
- - **In-memory sorting** - orderBy support without PouchDB indexes
60
- - **Pagination support** - Built-in pagination helpers
61
- - **PouchDB plugins** - Pre-configured with find, memory adapter, and json plugins
62
- - **Raw access** - Direct PouchDB database access via `.raw()` method
81
+ - **Schema Validation** - Input/output validation with Zod
82
+ - **Multiple Adapters** - IndexedDB, WebSQL, LevelDB, and in-memory
83
+ - **Conflict Resolution** - Built-in handling for sync conflicts
84
+ - **Raw Access** - Direct PouchDB database access via `.raw()` method
85
+
86
+ ## Documentation
87
+
88
+ For comprehensive documentation, see the [Fluent PouchDB docs](https://docs.goatlab.io/0.1.x/connectors/pouchdb.html).
89
+
90
+ ## License
91
+
92
+ MIT