@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 +46 -16
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -8
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
|
|
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
|
|
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
|
-
|
|
43
|
+
createdAt: z.date().optional()
|
|
27
44
|
})
|
|
28
45
|
|
|
29
46
|
// Create PouchDB instance
|
|
30
|
-
const db = new PouchDB('users'
|
|
47
|
+
const db = new PouchDB('users')
|
|
31
48
|
|
|
32
49
|
// Initialize connector
|
|
33
50
|
const users = new PouchDBConnector({
|
|
34
|
-
entity: UserEntity,
|
|
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: [{
|
|
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
|
-
- **
|
|
57
|
-
- **
|
|
58
|
-
- **
|
|
59
|
-
- **
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|