@truto/sqlite-builder 2.0.2-canary.24 → 2.0.2-canary.26
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 +22 -22
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
import sqlite3 from 'better-sqlite3'
|
|
1
|
+
// ❌ Unsafe types (will throw TypeError)
|
|
2
|
+
sql`SELECT * FROM users WHERE data = ${Buffer.from('test')}` // Use sql.raw() for buffers
|
|
3
|
+
sql`SELECT * FROM users WHERE id = ${Symbol('test')}` // Unsupported type
|
|
4
|
+
```
|
|
6
5
|
|
|
7
|
-
|
|
6
|
+
## 📋 Examples
|
|
8
7
|
|
|
9
|
-
|
|
10
|
-
// This is implementation-specific - check your SQLite setup
|
|
11
|
-
db.loadExtension('regexp') // Example - actual method may vary
|
|
8
|
+
### Basic CRUD Operations
|
|
12
9
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
email: { regex: '^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\\.[a-zA-Z]{2,}$' },
|
|
16
|
-
}
|
|
17
|
-
```
|
|
10
|
+
```typescript
|
|
11
|
+
import { sql } from '@truto/sqlite-builder'
|
|
18
12
|
|
|
19
|
-
|
|
13
|
+
// CREATE with array identifiers
|
|
14
|
+
const insertColumns = ['name', 'email', 'age']
|
|
15
|
+
const insertUser = sql`
|
|
16
|
+
INSERT INTO users (${sql.ident(insertColumns)})
|
|
17
|
+
VALUES (${name}, ${email}, ${age})
|
|
18
|
+
`
|
|
20
19
|
|
|
21
|
-
|
|
20
|
+
// READ with specific columns
|
|
21
|
+
const selectColumns = ['id', 'name', 'email', 'created_at']
|
|
22
|
+
const getUser = sql`
|
|
23
|
+
SELECT ${sql.ident(selectColumns)} FROM users
|
|
24
|
+
WHERE id = ${userId}
|
|
25
|
+
`
|
|
22
26
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
- **Placeholder integrity**: The `sql` tag rejects any query whose `?` count does not match its bound-value count, catching raw fragments that smuggle or drop placeholders
|
|
26
|
-
- **Safe `sql.join()` separators**: String separators are validated so they cannot introduce string literals, comments, statement terminators, or unbalanced parentheses; use a `SqlFragment` separator to parameterize the connector itself
|
|
27
|
-
- **Stacked Queries**: Queries containing `;` followed by additional SQL are rejected (detection ignores semicolons inside string literals and comments)
|
|
28
|
-
- **Identifier Safety**: `sql.ident()` validates against ANSI identifier rules and caps each part at 255 characters
|
|
27
|
+
// UPDATE
|
|
28
|
+
const updateUser = sql`
|
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.26","description":"debug canary","license":"MIT","main":"index.js"}
|