@truto/sqlite-builder 2.0.2-canary.20 → 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.
- package/README.md +23 -23
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
],
|
|
2
|
+
}
|
|
3
|
+
```
|
|
4
|
+
|
|
5
|
+
### Integration with SQL Template
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
import { sql, compileFilter } from '@truto/sqlite-builder'
|
|
3
9
|
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
},
|
|
10
|
+
// Build the WHERE clause
|
|
11
|
+
const filter = {
|
|
12
|
+
status: 'ACTIVE',
|
|
13
|
+
age: { gte: 18 },
|
|
14
|
+
role: { in: ['USER', 'ADMIN'] },
|
|
10
15
|
}
|
|
11
16
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
FROM users u
|
|
21
|
-
JOIN profiles p ON u.id = p.user_id
|
|
22
|
-
JOIN orders ro ON u.id = ro.user_id
|
|
23
|
-
WHERE ${compileFilter(userOrderFilter)}
|
|
24
|
-
GROUP BY u.id, u.name, u.email, p.verified_at
|
|
25
|
-
HAVING recent_order_count > 0
|
|
26
|
-
ORDER BY recent_order_total DESC
|
|
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}
|
|
27
25
|
`
|
|
28
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.
|
|
1
|
+
{"name":"@truto/sqlite-builder","version":"2.0.2-canary.22","description":"debug canary","license":"MIT","main":"index.js"}
|