mirror of
https://github.com/Jermolene/TiddlyWiki5
synced 2024-10-03 01:10:45 +00:00
Test code to exercise the database
This commit is contained in:
parent
146a22b894
commit
449e2274e2
@ -52,6 +52,10 @@ self.sqlite3InitModuleState.urlParams.set("sqlite3.wasm",blobUrl);
|
|||||||
self.sqlite3InitModule().then((sqlite3)=>{
|
self.sqlite3InitModule().then((sqlite3)=>{
|
||||||
// Save a reference to the sqlite3 object
|
// Save a reference to the sqlite3 object
|
||||||
$tw.sqlite3 = sqlite3;
|
$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
|
// Boot TiddlyWiki
|
||||||
$tw.boot.boot();
|
$tw.boot.boot();
|
||||||
});
|
});
|
||||||
|
@ -18,6 +18,29 @@ $tw.boot.preloadDirty = $tw.boot.preloadDirty || [];
|
|||||||
$tw.boot.suppressBoot = true;
|
$tw.boot.suppressBoot = true;
|
||||||
|
|
||||||
$tw.Wiki = function(options) {
|
$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 || {};
|
options = options || {};
|
||||||
var self = this,
|
var self = this,
|
||||||
tiddlers = Object.create(null), // Hashmap of tiddlers
|
tiddlers = Object.create(null), // Hashmap of tiddlers
|
||||||
|
Loading…
Reference in New Issue
Block a user