@goatlab/fluent-pouchdb 0.7.13 → 0.8.0
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 +54 -41
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -8
package/README.md
CHANGED
|
@@ -1,49 +1,62 @@
|
|
|
1
|
-
|
|
1
|
+
# @goatlab/fluent-pouchdb
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
[![Issues][issues-shield]][issues-url]
|
|
5
|
-
[![MIT License][license-shield]][license-url]
|
|
6
|
-
[](http://commitizen.github.io/cz-cli/)
|
|
3
|
+
PouchDB connector for the Goat Fluent query interface. Enables you to use PouchDB with the same unified API as other Fluent database connectors.
|
|
7
4
|
|
|
8
|
-
|
|
9
|
-
<br />
|
|
10
|
-
<p align="center">
|
|
11
|
-
<a href="https://github.com/github_username/repo">
|
|
12
|
-
<img src="https://docs.goatlab.io/logo.png" alt="Logo" width="150" height="150">
|
|
13
|
-
</a>
|
|
14
|
-
|
|
15
|
-
<h3 align="center">GOAT - FLUENT-POUCHDB</h3>
|
|
16
|
-
|
|
17
|
-
<p align="center">
|
|
18
|
-
Fluent - Time Saving (TS) utils
|
|
19
|
-
<br />
|
|
20
|
-
<a href="https://docs.goatlab.io/#/0.7.x/fluent/fluent"><strong>Explore the docs »</strong></a>
|
|
21
|
-
<br />
|
|
22
|
-
<br />
|
|
23
|
-
·
|
|
24
|
-
<a href="https://github.com/goat-io/fluent/issues">Report Bug</a>
|
|
25
|
-
·
|
|
26
|
-
<a href="https://github.com/goat-io/fluent/issues">Request Feature</a>
|
|
27
|
-
</p>
|
|
28
|
-
</p>
|
|
29
|
-
</p>
|
|
30
|
-
|
|
31
|
-
# Goat - Fluent
|
|
32
|
-
|
|
33
|
-
Fluent query interface for Multiple database types and helpers for fast API generation and general App building.
|
|
34
|
-
|
|
35
|
-
## Supported Databases
|
|
36
|
-
|
|
37
|
-
1. PouchDB
|
|
38
|
-
|
|
39
|
-
### Installing
|
|
40
|
-
|
|
41
|
-
To install this package in your project, you can use the following command within your terminal.
|
|
5
|
+
## Installation
|
|
42
6
|
|
|
43
7
|
```bash
|
|
8
|
+
npm install @goatlab/fluent-pouchdb
|
|
9
|
+
# or
|
|
44
10
|
yarn add @goatlab/fluent-pouchdb
|
|
11
|
+
# or
|
|
12
|
+
pnpm add @goatlab/fluent-pouchdb
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Basic Usage
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import { PouchDBConnector, PouchDB } from '@goatlab/fluent-pouchdb'
|
|
19
|
+
import { z } from 'zod'
|
|
20
|
+
|
|
21
|
+
// Define your schema
|
|
22
|
+
const UserSchema = z.object({
|
|
23
|
+
id: z.string(),
|
|
24
|
+
name: z.string(),
|
|
25
|
+
email: z.string().email(),
|
|
26
|
+
created: z.date().optional()
|
|
27
|
+
})
|
|
28
|
+
|
|
29
|
+
// Create PouchDB instance
|
|
30
|
+
const db = new PouchDB('users', { adapter: 'memory' }) // or use 'leveldb' for persistence
|
|
31
|
+
|
|
32
|
+
// Initialize connector
|
|
33
|
+
const users = new PouchDBConnector({
|
|
34
|
+
entity: UserEntity, // Your entity class with decorators
|
|
35
|
+
dataSource: db,
|
|
36
|
+
inputSchema: UserSchema,
|
|
37
|
+
outputSchema: UserSchema // optional, defaults to inputSchema
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
// Use Fluent API
|
|
41
|
+
const user = await users.insert({
|
|
42
|
+
name: 'John Doe',
|
|
43
|
+
email: 'john@example.com'
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
const found = await users.findMany({
|
|
47
|
+
where: { email: { equals: 'john@example.com' } },
|
|
48
|
+
orderBy: [{ created: 'desc' }],
|
|
49
|
+
limit: 10
|
|
50
|
+
})
|
|
45
51
|
```
|
|
46
52
|
|
|
47
|
-
|
|
53
|
+
## Key Features
|
|
48
54
|
|
|
49
|
-
|
|
55
|
+
- **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
|