@travetto/model-sqlite 4.1.2 → 5.0.0-rc.0
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/package.json +8 -8
- package/src/connection.ts +6 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@travetto/model-sqlite",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.0-rc.0",
|
|
4
4
|
"description": "SQLite backing for the travetto model module, with real-time modeling support for SQL schemas.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"sql",
|
|
@@ -26,13 +26,13 @@
|
|
|
26
26
|
"directory": "module/model-sqlite"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@travetto/config": "^
|
|
30
|
-
"@travetto/context": "^
|
|
31
|
-
"@travetto/model": "^
|
|
32
|
-
"@travetto/model-query": "^
|
|
33
|
-
"@travetto/model-sql": "^
|
|
34
|
-
"@types/better-sqlite3": "^7.6.
|
|
35
|
-
"better-sqlite3": "^
|
|
29
|
+
"@travetto/config": "^5.0.0-rc.0",
|
|
30
|
+
"@travetto/context": "^5.0.0-rc.0",
|
|
31
|
+
"@travetto/model": "^5.0.0-rc.0",
|
|
32
|
+
"@travetto/model-query": "^5.0.0-rc.0",
|
|
33
|
+
"@travetto/model-sql": "^5.0.0-rc.0",
|
|
34
|
+
"@types/better-sqlite3": "^7.6.11",
|
|
35
|
+
"better-sqlite3": "^11.1.2"
|
|
36
36
|
},
|
|
37
37
|
"travetto": {
|
|
38
38
|
"displayName": "SQLite Model Service"
|
package/src/connection.ts
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import fs from 'node:fs/promises';
|
|
2
|
+
import path from 'node:path';
|
|
3
|
+
|
|
2
4
|
import sqlDb, { type Database, Options } from 'better-sqlite3';
|
|
3
5
|
import { Pool, createPool } from 'generic-pool';
|
|
4
6
|
|
|
5
|
-
import { RuntimeContext
|
|
7
|
+
import { RuntimeContext } from '@travetto/manifest';
|
|
6
8
|
import { ShutdownManager, Util } from '@travetto/base';
|
|
7
9
|
import { AsyncContext, WithAsyncContext } from '@travetto/context';
|
|
8
10
|
import { ExistsError } from '@travetto/model';
|
|
@@ -48,6 +50,7 @@ export class SqliteConnection extends Connection<Database> {
|
|
|
48
50
|
const db = new sqlDb(file, this.#config.options);
|
|
49
51
|
await db.pragma('foreign_keys = ON');
|
|
50
52
|
await db.pragma('journal_mode = WAL');
|
|
53
|
+
await db.pragma('synchronous = NORMAL');
|
|
51
54
|
db.function('regexp', (a, b) => new RegExp(`${a}`).test(`${b}`) ? 1 : 0);
|
|
52
55
|
return db;
|
|
53
56
|
}
|
|
@@ -57,6 +60,8 @@ export class SqliteConnection extends Connection<Database> {
|
|
|
57
60
|
*/
|
|
58
61
|
@WithAsyncContext()
|
|
59
62
|
override async init(): Promise<void> {
|
|
63
|
+
this.transactionDialect = { ...this.transactionDialect, begin: 'BEGIN IMMEDIATE;' };
|
|
64
|
+
|
|
60
65
|
await this.#create();
|
|
61
66
|
|
|
62
67
|
this.#pool = createPool<Database>({
|