@spinajs/orm-sqlite 2.0.490 → 2.0.494

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,71 +1,71 @@
1
- # `@spinajs/orm-sqlite`
2
-
3
- The SQLite dialect driver for [`@spinajs/orm`](../orm), built on
4
- [`@spinajs/orm-sql`](../orm-sql).
5
-
6
- ## Install
7
-
8
- ```bash
9
- npm install @spinajs/orm @spinajs/orm-sqlite
10
- ```
11
-
12
- ## Usage
13
-
14
- ```ts
15
- import { DI } from '@spinajs/di';
16
- import { Orm } from '@spinajs/orm';
17
- import { SqliteOrmDriver } from '@spinajs/orm-sqlite';
18
-
19
- DI.register(SqliteOrmDriver).as('orm-driver-sqlite');
20
- await DI.resolve(Orm);
21
- ```
22
-
23
- ```ts
24
- // configuration
25
- {
26
- db: {
27
- DefaultConnection: 'sqlite',
28
- Connections: [
29
- {
30
- Name: 'sqlite',
31
- Driver: 'orm-driver-sqlite',
32
- Filename: './data/app.sqlite', // or ':memory:'
33
- Pool: { Max: 4 }, // sizes the READ-ONLY handle pool
34
- Migration: { OnStartup: true },
35
- },
36
- ],
37
- },
38
- }
39
- ```
40
-
41
- ## What is distinctive
42
-
43
- - **`Pool.Max` sizes read-only handles, not writers.** SQLite serializes writers at the file
44
- level, so extra writer handles buy nothing and invite `SQLITE_BUSY`. The driver opens
45
- `Max - 1` read handles instead, skipped entirely for `:memory:` and anonymous temporary
46
- databases.
47
- - **The only driver with `RETURNING`** (`insertReturning: true`), so generated keys come back
48
- exactly — including from multi-row inserts.
49
- - **`SERIALIZABLE` is the only isolation level**, because sqlite3 outside shared-cache mode
50
- serializes file access and that *is* SERIALIZABLE.
51
- - **No database events**, **no `TRUNCATE`** (a `DELETE` stands in, and the auto-increment counter
52
- is not reset), and **multi-column `ORDER BY` is reduced to one column**.
53
- - **No auto-increment column inside a composite primary key** — the compiler throws rather than
54
- emit invalid SQL.
55
-
56
- ## Documentation
57
-
58
- Full documentation lives in **[docs/](docs/)**.
59
-
60
- | | Page |
61
- | --- | --- |
62
- | 01 | [Configuration](docs/01-configuration.md) |
63
- | 02 | [Dialect notes](docs/02-dialect-notes.md) |
64
-
65
- ## Development
66
-
67
- ```bash
68
- npm test # unit suite, no server needed
69
- npm run test:integration # creates and removes a temporary on-disk database
70
- npm run build
71
- ```
1
+ # `@spinajs/orm-sqlite`
2
+
3
+ The SQLite dialect driver for [`@spinajs/orm`](../orm), built on
4
+ [`@spinajs/orm-sql`](../orm-sql).
5
+
6
+ ## Install
7
+
8
+ ```bash
9
+ npm install @spinajs/orm @spinajs/orm-sqlite
10
+ ```
11
+
12
+ ## Usage
13
+
14
+ ```ts
15
+ import { DI } from '@spinajs/di';
16
+ import { Orm } from '@spinajs/orm';
17
+ import { SqliteOrmDriver } from '@spinajs/orm-sqlite';
18
+
19
+ DI.register(SqliteOrmDriver).as('orm-driver-sqlite');
20
+ await DI.resolve(Orm);
21
+ ```
22
+
23
+ ```ts
24
+ // configuration
25
+ {
26
+ db: {
27
+ DefaultConnection: 'sqlite',
28
+ Connections: [
29
+ {
30
+ Name: 'sqlite',
31
+ Driver: 'orm-driver-sqlite',
32
+ Filename: './data/app.sqlite', // or ':memory:'
33
+ Pool: { Max: 4 }, // sizes the READ-ONLY handle pool
34
+ Migration: { OnStartup: true },
35
+ },
36
+ ],
37
+ },
38
+ }
39
+ ```
40
+
41
+ ## What is distinctive
42
+
43
+ - **`Pool.Max` sizes read-only handles, not writers.** SQLite serializes writers at the file
44
+ level, so extra writer handles buy nothing and invite `SQLITE_BUSY`. The driver opens
45
+ `Max - 1` read handles instead, skipped entirely for `:memory:` and anonymous temporary
46
+ databases.
47
+ - **The only driver with `RETURNING`** (`insertReturning: true`), so generated keys come back
48
+ exactly — including from multi-row inserts.
49
+ - **`SERIALIZABLE` is the only isolation level**, because sqlite3 outside shared-cache mode
50
+ serializes file access and that *is* SERIALIZABLE.
51
+ - **No database events**, **no `TRUNCATE`** (a `DELETE` stands in, and the auto-increment counter
52
+ is not reset), and **multi-column `ORDER BY` is reduced to one column**.
53
+ - **No auto-increment column inside a composite primary key** — the compiler throws rather than
54
+ emit invalid SQL.
55
+
56
+ ## Documentation
57
+
58
+ Full documentation lives in **[docs/](docs/)**.
59
+
60
+ | | Page |
61
+ | --- | --- |
62
+ | 01 | [Configuration](docs/01-configuration.md) |
63
+ | 02 | [Dialect notes](docs/02-dialect-notes.md) |
64
+
65
+ ## Development
66
+
67
+ ```bash
68
+ npm test # unit suite, no server needed
69
+ npm run test:integration # creates and removes a temporary on-disk database
70
+ npm run build
71
+ ```