@goatlab/fluent-loki 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,55 +1,50 @@
1
1
  # @goatlab/fluent-loki
2
2
 
3
- LokiJS connector for the Goat Fluent query interface. Provides in-memory database capabilities with multiple storage adapters including IndexedDB, file system, and encrypted storage.
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 your schema
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 LokiJS database instance
25
+ // Create database
30
26
  const db = Loki.createDb({
31
27
  dbName: 'myapp',
32
- storage: LokiStorageType.memory // or indexedDB, file, fsStructured, cryptedFile
28
+ storage: LokiStorageType.memory
33
29
  })
34
30
 
35
- // Create a User entity
36
- class User {
37
- static name = 'User'
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 the Fluent query interface
49
- const users = await userConnector.findMany({
50
- where: {
51
- age: { gte: 18 }
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
- - **Multiple Storage Adapters**: Memory, IndexedDB, file system, structured file system, and encrypted file storage
61
- - **Fluent Query Interface**: Chainable query methods compatible with Goat Fluent
62
- - **Schema Validation**: Built-in Zod schema validation for input and output
63
- - **TypeScript Support**: Full type safety with generics
64
- - **Automatic ID Generation**: UUID-based ID generation for new records
65
- - **Pagination Support**: Built-in pagination with offset and limit
66
- - **Complex Queries**: Support for AND/OR conditions, nested properties, and various operators
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