@truto/sqlite-builder 2.0.2-canary.21 → 2.0.2-canary.22

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.
Files changed (2) hide show
  1. package/README.md +22 -22
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,28 +1,28 @@
1
- const results = db.prepare(complexQuery.text).all(...complexQuery.values)
1
+ ],
2
+ }
2
3
  ```
3
4
 
4
- #### Kitchen Sink Examples
5
-
6
- Real-world complex filters:
5
+ ### Integration with SQL Template
7
6
 
8
7
  ```typescript
9
- // Active users in specific regions, either minors/seniors or VIP
10
- const complexFilter = {
11
- and: [
12
- { status: 'ACTIVE' },
13
- { or: [{ age: { lt: 18 } }, { age: { gte: 65 } }, { membership: 'VIP' }] },
14
- { country: { in: ['US', 'CA', 'GB'] } },
15
- { email: { exists: true } },
16
- { 'profile.verified': true },
17
- ],
8
+ import { sql, compileFilter } from '@truto/sqlite-builder'
9
+
10
+ // Build the WHERE clause
11
+ const filter = {
12
+ status: 'ACTIVE',
13
+ age: { gte: 18 },
14
+ role: { in: ['USER', 'ADMIN'] },
18
15
  }
19
16
 
20
- // Content filtering with multiple criteria
21
- const contentFilter = {
22
- name: { like: 'Project%' },
23
- category: { nin: ['ARCHIVED', 'DELETED', 'SPAM'] },
24
- created_at: { exists: true },
25
- or: [
26
- { tags: { ilike: '%important%' } },
27
- { priority: { gte: 8 } },
28
- { 'metadata.featured': true },
17
+ // Use in complete query — the filter fragment and the LIMIT value are
18
+ // collected in order, so query.values lines up with the placeholders.
19
+ const query = sql`
20
+ SELECT id, name, email, created_at
21
+ FROM users
22
+ WHERE ${compileFilter(filter)}
23
+ ORDER BY created_at DESC
24
+ LIMIT ${limit}
25
+ `
26
+
27
+ // Execute with driver
28
+ const results = db.prepare(query.text).all(...query.values)
package/package.json CHANGED
@@ -1 +1 @@
1
- {"name":"@truto/sqlite-builder","version":"2.0.2-canary.21","description":"debug canary","license":"MIT","main":"index.js"}
1
+ {"name":"@truto/sqlite-builder","version":"2.0.2-canary.22","description":"debug canary","license":"MIT","main":"index.js"}