@dockstat/sqlite-wrapper 1.2.6 → 1.2.8
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/LICENSE +373 -373
- package/README.md +99 -66
- package/index.ts +858 -840
- package/package.json +54 -54
- package/query-builder/base.ts +221 -221
- package/query-builder/delete.ts +352 -352
- package/query-builder/index.ts +431 -431
- package/query-builder/insert.ts +249 -249
- package/query-builder/select.ts +358 -358
- package/query-builder/update.ts +278 -278
- package/query-builder/where.ts +307 -307
- package/types.ts +623 -623
package/README.md
CHANGED
|
@@ -1,66 +1,99 @@
|
|
|
1
|
-
# @dockstat/sqlite-wrapper
|
|
2
|
-
|
|
3
|
-

|
|
4
|
-

|
|
5
|
-

|
|
6
|
-
|
|
7
|
-
**A fast, type-safe TypeScript wrapper for Bun's `bun:sqlite`.**
|
|
8
|
-
Schema-first table helpers, an expressive chainable QueryBuilder, safe defaults (WHERE required for destructive ops), JSON + generated columns, and production-minded pragmas & transactions.
|
|
9
|
-
|
|
10
|
-
## Install
|
|
11
|
-
> Requires **Bun** runtime
|
|
12
|
-
|
|
13
|
-
```bash
|
|
14
|
-
bun add @dockstat/sqlite-wrapper
|
|
15
|
-
````
|
|
16
|
-
|
|
17
|
-
## 10-second quickstart
|
|
18
|
-
|
|
19
|
-
```
|
|
20
|
-
import { DB, column } from "@dockstat/sqlite-wrapper";
|
|
21
|
-
|
|
22
|
-
type User = {
|
|
23
|
-
id?: number,
|
|
24
|
-
name: string,
|
|
25
|
-
active: boolean,
|
|
26
|
-
email: string,
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
const db = new DB("app.db", {
|
|
30
|
-
pragmas: [
|
|
31
|
-
["journal_mode","WAL"],
|
|
32
|
-
["foreign_keys","ON"]
|
|
33
|
-
]
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
const userTable = db.createTable<User>("users", {
|
|
37
|
-
id: column.id(),
|
|
38
|
-
name: column.text({ notNull: true }),
|
|
39
|
-
active: column.boolean(),
|
|
40
|
-
email: column.text({ unique: true, notNull: true }),
|
|
41
|
-
created_at: column.createdAt()
|
|
42
|
-
});
|
|
43
|
-
|
|
44
|
-
const users = userTable
|
|
45
|
-
.select(["id","name","email"])
|
|
46
|
-
.where({ active: true })
|
|
47
|
-
.orderBy("created_at").desc()
|
|
48
|
-
.limit(10)
|
|
49
|
-
.all();
|
|
50
|
-
```
|
|
51
|
-
|
|
52
|
-
## Why use it?
|
|
53
|
-
|
|
54
|
-
* ⚡ Bun-native, high-performance bindings
|
|
55
|
-
* 🔒 Type-safe table & query APIs (compile-time checks)
|
|
56
|
-
* 🧭 Full SQLite feature support: JSON, generated columns, foreign keys, indexes
|
|
57
|
-
* 🛡️ Safety-first defaults — prevents accidental full-table updates/deletes
|
|
58
|
-
* 🚀 Designed for production workflows: WAL, pragmatic PRAGMAs, bulk ops, transactions
|
|
59
|
-
|
|
60
|
-
##
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
1
|
+
# @dockstat/sqlite-wrapper
|
|
2
|
+
|
|
3
|
+

|
|
4
|
+

|
|
5
|
+

|
|
6
|
+
|
|
7
|
+
**A fast, type-safe TypeScript wrapper for Bun's `bun:sqlite`.**
|
|
8
|
+
Schema-first table helpers, an expressive chainable QueryBuilder, safe defaults (WHERE required for destructive ops), JSON + generated columns, and production-minded pragmas & transactions.
|
|
9
|
+
|
|
10
|
+
## Install
|
|
11
|
+
> Requires **Bun** runtime
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
bun add @dockstat/sqlite-wrapper
|
|
15
|
+
````
|
|
16
|
+
|
|
17
|
+
## 10-second quickstart
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import { DB, column } from "@dockstat/sqlite-wrapper";
|
|
21
|
+
|
|
22
|
+
type User = {
|
|
23
|
+
id?: number,
|
|
24
|
+
name: string,
|
|
25
|
+
active: boolean,
|
|
26
|
+
email: string,
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const db = new DB("app.db", {
|
|
30
|
+
pragmas: [
|
|
31
|
+
["journal_mode","WAL"],
|
|
32
|
+
["foreign_keys","ON"]
|
|
33
|
+
]
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const userTable = db.createTable<User>("users", {
|
|
37
|
+
id: column.id(),
|
|
38
|
+
name: column.text({ notNull: true }),
|
|
39
|
+
active: column.boolean(),
|
|
40
|
+
email: column.text({ unique: true, notNull: true }),
|
|
41
|
+
created_at: column.createdAt()
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
const users = userTable
|
|
45
|
+
.select(["id","name","email"])
|
|
46
|
+
.where({ active: true })
|
|
47
|
+
.orderBy("created_at").desc()
|
|
48
|
+
.limit(10)
|
|
49
|
+
.all();
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
## Why use it?
|
|
53
|
+
|
|
54
|
+
* ⚡ Bun-native, high-performance bindings
|
|
55
|
+
* 🔒 Type-safe table & query APIs (compile-time checks)
|
|
56
|
+
* 🧭 Full SQLite feature support: JSON, generated columns, foreign keys, indexes
|
|
57
|
+
* 🛡️ Safety-first defaults — prevents accidental full-table updates/deletes
|
|
58
|
+
* 🚀 Designed for production workflows: WAL, pragmatic PRAGMAs, bulk ops, transactions
|
|
59
|
+
|
|
60
|
+
## Core Features
|
|
61
|
+
|
|
62
|
+
### Type Safety
|
|
63
|
+
|
|
64
|
+
* **Compile-time validation** of column names and data shapes
|
|
65
|
+
* **IntelliSense support** for all operations
|
|
66
|
+
* **Generic interfaces** that adapt to your data models
|
|
67
|
+
* **Type-safe column definitions** with comprehensive constraint support
|
|
68
|
+
|
|
69
|
+
### Safety-First Design
|
|
70
|
+
|
|
71
|
+
* **Mandatory WHERE conditions** for UPDATE and DELETE operations to prevent accidental data loss
|
|
72
|
+
* **Parameter binding** for all queries to prevent SQL injection
|
|
73
|
+
* **Prepared statements** used internally for optimal performance
|
|
74
|
+
* **Transaction support** with automatic rollback on errors
|
|
75
|
+
|
|
76
|
+
### Production Ready
|
|
77
|
+
|
|
78
|
+
* **WAL mode** support for concurrent read/write operations
|
|
79
|
+
* **Comprehensive PRAGMA management** for performance tuning
|
|
80
|
+
* **Connection pooling** considerations built-in
|
|
81
|
+
* **Bulk operation** support with transaction batching
|
|
82
|
+
* **Schema introspection** tools for migrations and debugging
|
|
83
|
+
|
|
84
|
+
### Complete SQLite Support
|
|
85
|
+
|
|
86
|
+
* **All SQLite data types** with proper TypeScript mappings
|
|
87
|
+
* **Generated columns** (both VIRTUAL and STORED)
|
|
88
|
+
* **Foreign key constraints** with cascade options
|
|
89
|
+
* **JSON columns** with validation and transformation
|
|
90
|
+
* **Full-text search** preparation
|
|
91
|
+
* **Custom functions** and extensions support
|
|
92
|
+
|
|
93
|
+
## Docs & examples
|
|
94
|
+
|
|
95
|
+
See full technical docs [here](https://outline.itsnik.de/s/9d88c471-373e-4ef2-a955-b1058eb7dc99/doc/dockstatsqlite-wrapper-Lxt4IphXI5).
|
|
96
|
+
|
|
97
|
+
## License
|
|
98
|
+
|
|
99
|
+
MPL-2.0 — maintained by Dockstat. Contributions welcome.
|