@easy-cms/db-sqlite 0.9.0 → 0.10.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/README.md +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.js +8 -2
- package/package.json +5 -5
package/README.md
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -7,6 +7,11 @@ interface SQLiteAdapterOptions extends DrizzleAdapterOptions {
|
|
|
7
7
|
readonly url: string;
|
|
8
8
|
/** Auth token for Turso / remote libSQL. */
|
|
9
9
|
readonly authToken?: string;
|
|
10
|
+
/**
|
|
11
|
+
* Local files: how long (ms) a write waits while another process (a second server, the CLI)
|
|
12
|
+
* is writing to the same file. Default 10000.
|
|
13
|
+
*/
|
|
14
|
+
readonly busyTimeout?: number;
|
|
10
15
|
}
|
|
11
16
|
declare const sqliteDialect: Dialect;
|
|
12
17
|
/** SQLite / libSQL database adapter. */
|
package/dist/index.js
CHANGED
|
@@ -57,6 +57,7 @@ var sqliteDialect = {
|
|
|
57
57
|
);
|
|
58
58
|
return sql`(select ${value} from ${sql.join(from, sql`, `)} where ${value} is not null order by ${order} limit 1)`;
|
|
59
59
|
},
|
|
60
|
+
backupSQL: (file) => `VACUUM INTO '${file.replaceAll("'", "''")}'`,
|
|
60
61
|
param: () => "?",
|
|
61
62
|
migrationsTableSQL: (name) => `CREATE TABLE IF NOT EXISTS \`${name}\` (
|
|
62
63
|
\`id\` integer PRIMARY KEY AUTOINCREMENT NOT NULL,
|
|
@@ -73,14 +74,19 @@ function sqlite(options) {
|
|
|
73
74
|
return {
|
|
74
75
|
name: "sqlite",
|
|
75
76
|
init: async (args) => {
|
|
77
|
+
const url = resolveUrl(options.url, args.cwd);
|
|
76
78
|
const client = createClient({
|
|
77
|
-
url
|
|
78
|
-
...options.authToken ? { authToken: options.authToken } : {}
|
|
79
|
+
url,
|
|
80
|
+
...options.authToken ? { authToken: options.authToken } : {},
|
|
81
|
+
// SQLite has one writer. Writes in this process share a queue (`writeQueue`); this waits
|
|
82
|
+
// for other processes. Its wait blocks the process, but only for another's short write.
|
|
83
|
+
timeout: options.busyTimeout ?? 1e4
|
|
79
84
|
});
|
|
80
85
|
if (options.url.startsWith("file:")) await client.execute("PRAGMA journal_mode = WAL");
|
|
81
86
|
const toStatement = (s) => ({ sql: s.sql, args: [...s.params ?? []] });
|
|
82
87
|
const connection = {
|
|
83
88
|
db: drizzle(client),
|
|
89
|
+
writeQueue: url,
|
|
84
90
|
runner: {
|
|
85
91
|
async query(text2, params = []) {
|
|
86
92
|
const result = await client.execute({ sql: text2, args: [...params] });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@easy-cms/db-sqlite",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.10.0",
|
|
4
4
|
"description": "SQLite / libSQL database adapter for Easy CMS",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -22,21 +22,21 @@
|
|
|
22
22
|
"@libsql/client": "^0.18.0",
|
|
23
23
|
"drizzle-kit": "0.31.11",
|
|
24
24
|
"drizzle-orm": "0.45.3",
|
|
25
|
-
"@easy-cms/drizzle": "^0.
|
|
25
|
+
"@easy-cms/drizzle": "^0.10.0"
|
|
26
26
|
},
|
|
27
27
|
"peerDependencies": {
|
|
28
|
-
"@easy-cms/core": "^0.
|
|
28
|
+
"@easy-cms/core": "^0.10.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"sharp": "^0.35.4",
|
|
32
|
-
"@easy-cms/core": "^0.
|
|
32
|
+
"@easy-cms/core": "^0.10.0"
|
|
33
33
|
},
|
|
34
34
|
"publishConfig": {
|
|
35
35
|
"access": "public"
|
|
36
36
|
},
|
|
37
37
|
"repository": {
|
|
38
38
|
"type": "git",
|
|
39
|
-
"url": "git+https://github.com/maritonx/easy-
|
|
39
|
+
"url": "git+https://github.com/maritonx/easy-cms.git",
|
|
40
40
|
"directory": "packages/db-sqlite"
|
|
41
41
|
},
|
|
42
42
|
"keywords": [
|