diff --git a/plugins/tiddlywiki/sqlite3store/rawmarkup-bottombody.js b/plugins/tiddlywiki/sqlite3store/rawmarkup-bottombody.js index 06a32e35e..826c49693 100644 --- a/plugins/tiddlywiki/sqlite3store/rawmarkup-bottombody.js +++ b/plugins/tiddlywiki/sqlite3store/rawmarkup-bottombody.js @@ -52,6 +52,10 @@ self.sqlite3InitModuleState.urlParams.set("sqlite3.wasm",blobUrl); self.sqlite3InitModule().then((sqlite3)=>{ // Save a reference to the sqlite3 object $tw.sqlite3 = sqlite3; + var capi = $tw.sqlite3.capi, // C-style API + oo = $tw.sqlite3.oo1; // High-level OO API + // Get version numbers + console.log("sqlite3 version",capi.sqlite3_libversion()); // Boot TiddlyWiki $tw.boot.boot(); }); diff --git a/plugins/tiddlywiki/sqlite3store/rawmarkup.js b/plugins/tiddlywiki/sqlite3store/rawmarkup.js index d28ec5e19..db4473e33 100644 --- a/plugins/tiddlywiki/sqlite3store/rawmarkup.js +++ b/plugins/tiddlywiki/sqlite3store/rawmarkup.js @@ -18,6 +18,29 @@ $tw.boot.preloadDirty = $tw.boot.preloadDirty || []; $tw.boot.suppressBoot = true; $tw.Wiki = function(options) { + var capi = $tw.sqlite3.capi, // C-style API + oo = $tw.sqlite3.oo1; // High-level OO API + // Create a test database and store and retrieve some data + var db = new oo.DB("/tiddlywiki.sqlite3","ct"); + db.exec({ + sql:"CREATE TABLE IF NOT EXISTS t(a,b)" + }); + db.exec({ + sql: "insert into t(a,b) values (?,?)", + bind: [3, 1415926] + }); + db.exec({ + sql: "insert into t(a,b) values (?,?)", + bind: [1, 4142136] + }); + let resultRows = []; + db.exec({ + sql: "select a, b from t order by a limit 3", + rowMode: "object", + resultRows: resultRows + }); + console.log("Result rows:",JSON.stringify(resultRows,undefined,2)); + // Plain JS wiki store implementation follows options = options || {}; var self = this, tiddlers = Object.create(null), // Hashmap of tiddlers