@goatlab/fluent-loki 0.8.0 → 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 +29 -30
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -1,55 +1,50 @@
|
|
|
1
1
|
# @goatlab/fluent-loki
|
|
2
2
|
|
|
3
|
-
LokiJS connector for
|
|
3
|
+
LokiJS connector for Goat Fluent - a fast, in-memory database adapter with optional persistence.
|
|
4
4
|
|
|
5
5
|
## Installation
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
8
|
npm install @goatlab/fluent-loki
|
|
9
|
-
# or
|
|
10
|
-
yarn add @goatlab/fluent-loki
|
|
11
|
-
# or
|
|
12
|
-
pnpm add @goatlab/fluent-loki
|
|
13
9
|
```
|
|
14
10
|
|
|
15
|
-
## Usage
|
|
11
|
+
## Basic Usage
|
|
16
12
|
|
|
17
13
|
```typescript
|
|
18
14
|
import { Loki, LokiConnector, LokiStorageType } from '@goatlab/fluent-loki'
|
|
19
15
|
import { z } from 'zod'
|
|
20
16
|
|
|
21
|
-
// Define
|
|
17
|
+
// Define schema
|
|
22
18
|
const UserSchema = z.object({
|
|
23
19
|
id: z.string(),
|
|
24
20
|
name: z.string(),
|
|
25
21
|
email: z.string().email(),
|
|
26
|
-
age: z.number()
|
|
22
|
+
age: z.number().optional()
|
|
27
23
|
})
|
|
28
24
|
|
|
29
|
-
// Create
|
|
25
|
+
// Create database
|
|
30
26
|
const db = Loki.createDb({
|
|
31
27
|
dbName: 'myapp',
|
|
32
|
-
storage: LokiStorageType.memory
|
|
28
|
+
storage: LokiStorageType.memory
|
|
33
29
|
})
|
|
34
30
|
|
|
35
|
-
// Create
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
// Initialize the connector
|
|
41
|
-
const userConnector = new LokiConnector({
|
|
42
|
-
entity: User,
|
|
31
|
+
// Create connector
|
|
32
|
+
const users = new LokiConnector({
|
|
33
|
+
entity: { name: 'User' },
|
|
43
34
|
dataSource: db,
|
|
44
35
|
inputSchema: UserSchema,
|
|
45
36
|
outputSchema: UserSchema
|
|
46
37
|
})
|
|
47
38
|
|
|
48
|
-
// Use
|
|
49
|
-
const
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
39
|
+
// Use Fluent API
|
|
40
|
+
const user = await users.insert({
|
|
41
|
+
name: 'John Doe',
|
|
42
|
+
email: 'john@example.com',
|
|
43
|
+
age: 30
|
|
44
|
+
})
|
|
45
|
+
|
|
46
|
+
const results = await users.findMany({
|
|
47
|
+
where: { age: { gte: 18 } },
|
|
53
48
|
orderBy: [{ name: 'asc' }],
|
|
54
49
|
limit: 10
|
|
55
50
|
})
|
|
@@ -57,10 +52,14 @@ const users = await userConnector.findMany({
|
|
|
57
52
|
|
|
58
53
|
## Key Features
|
|
59
54
|
|
|
60
|
-
- **
|
|
61
|
-
- **
|
|
62
|
-
- **
|
|
63
|
-
- **
|
|
64
|
-
- **
|
|
65
|
-
- **
|
|
66
|
-
- **
|
|
55
|
+
- **In-Memory Performance** - Lightning-fast operations ideal for testing and prototyping
|
|
56
|
+
- **Multiple Storage Options** - Memory, IndexedDB, file system, and encrypted storage
|
|
57
|
+
- **Fluent Query Interface** - Compatible with all Goat Fluent query patterns
|
|
58
|
+
- **Schema Validation** - Built-in Zod validation for type safety
|
|
59
|
+
- **Complex Queries** - Support for nested properties, AND/OR conditions, regex
|
|
60
|
+
- **Change Tracking** - Monitor document changes with event listeners
|
|
61
|
+
- **No External Dependencies** - Pure JavaScript implementation
|
|
62
|
+
|
|
63
|
+
## License
|
|
64
|
+
|
|
65
|
+
MIT
|