mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2025-01-24 07:56:52 +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
|
||||
- multi-wiki-support
|
||||
env:
|
||||
NODE_VERSION: "22"
|
||||
NODE_VERSION: "23"
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
|
@ -24,7 +24,7 @@ function SqlEngine(options) {
|
||||
// Initialise the statement cache
|
||||
this.statements = Object.create(null); // Hashmap by SQL text of statement objects
|
||||
// Choose engine
|
||||
this.engine = options.engine || "better"; // wasm | better
|
||||
this.engine = options.engine || "node"; // node | wasm | better
|
||||
// Create the database file directories if needed
|
||||
if(options.databasePath) {
|
||||
$tw.utils.createFileDirectories(options.databasePath);
|
||||
@ -33,6 +33,9 @@ function SqlEngine(options) {
|
||||
const databasePath = options.databasePath || ":memory:";
|
||||
let Database;
|
||||
switch(this.engine) {
|
||||
case "node":
|
||||
({ DatabaseSync: Database } = require("node:sqlite"));
|
||||
break;
|
||||
case "wasm":
|
||||
({ Database } = require("node-sqlite3-wasm"));
|
||||
break;
|
||||
|
@ -13,6 +13,10 @@ if($tw.node) {
|
||||
/*global $tw: false */
|
||||
"use strict";
|
||||
|
||||
describe("SQL tiddler database with node built-in sqlite", function() {
|
||||
runSqlDatabaseTests("node");
|
||||
});
|
||||
|
||||
describe("SQL tiddler database with node-sqlite3-wasm", function() {
|
||||
runSqlDatabaseTests("wasm");
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user