mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-02-09 07:30:01 +00:00
Add support for Node.js integrated sqlite
Available in Node.js 22.50 - see https://nodejs.org/api/sqlite.html Given the Node.js release timeline, I think it will be reasonable to switch to the integrated Node.js sqlite as the default, which will avoid all the npm install kerfuffle too.
This commit is contained in:
parent
739ba3288b
commit
19e341c760
2
.github/workflows/ci.yml
vendored
2
.github/workflows/ci.yml
vendored
@ -6,7 +6,7 @@ on:
|
|||||||
- tiddlywiki-com
|
- tiddlywiki-com
|
||||||
- multi-wiki-support
|
- multi-wiki-support
|
||||||
env:
|
env:
|
||||||
NODE_VERSION: "22"
|
NODE_VERSION: "23"
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
@ -24,7 +24,7 @@ function SqlEngine(options) {
|
|||||||
// Initialise the statement cache
|
// Initialise the statement cache
|
||||||
this.statements = Object.create(null); // Hashmap by SQL text of statement objects
|
this.statements = Object.create(null); // Hashmap by SQL text of statement objects
|
||||||
// Choose engine
|
// Choose engine
|
||||||
this.engine = options.engine || "better"; // wasm | better
|
this.engine = options.engine || "node"; // node | wasm | better
|
||||||
// Create the database file directories if needed
|
// Create the database file directories if needed
|
||||||
if(options.databasePath) {
|
if(options.databasePath) {
|
||||||
$tw.utils.createFileDirectories(options.databasePath);
|
$tw.utils.createFileDirectories(options.databasePath);
|
||||||
@ -33,6 +33,9 @@ function SqlEngine(options) {
|
|||||||
const databasePath = options.databasePath || ":memory:";
|
const databasePath = options.databasePath || ":memory:";
|
||||||
let Database;
|
let Database;
|
||||||
switch(this.engine) {
|
switch(this.engine) {
|
||||||
|
case "node":
|
||||||
|
({ DatabaseSync: Database } = require("node:sqlite"));
|
||||||
|
break;
|
||||||
case "wasm":
|
case "wasm":
|
||||||
({ Database } = require("node-sqlite3-wasm"));
|
({ Database } = require("node-sqlite3-wasm"));
|
||||||
break;
|
break;
|
||||||
|
@ -13,6 +13,10 @@ if($tw.node) {
|
|||||||
/*global $tw: false */
|
/*global $tw: false */
|
||||||
"use strict";
|
"use strict";
|
||||||
|
|
||||||
|
describe("SQL tiddler database with node built-in sqlite", function() {
|
||||||
|
runSqlDatabaseTests("node");
|
||||||
|
});
|
||||||
|
|
||||||
describe("SQL tiddler database with node-sqlite3-wasm", function() {
|
describe("SQL tiddler database with node-sqlite3-wasm", function() {
|
||||||
runSqlDatabaseTests("wasm");
|
runSqlDatabaseTests("wasm");
|
||||||
});
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user