Skip to content
Browse files

Use SQLite3JS for WinRT backend

  • Loading branch information...
1 parent 0fdb37d commit e2a27394561589d931c231cf78319c7bb7ddc668 @superquadratic superquadratic committed
Showing with 3 additions and 51 deletions.
  1. +3 −51 lib/persistence.store.sqlite3_winrt.js
View
54 lib/persistence.store.sqlite3_winrt.js
@@ -15,7 +15,7 @@ if(!persistence.store) {
persistence.store.sqlite3_winrt = {};
persistence.store.sqlite3_winrt.config = function(persistence, dbPath) {
- var db = new SQLite3.Database(dbPath);
+ var db = new SQLite3JS.Database(dbPath);
persistence.transaction = function (explicitCommit, fn) {
if (typeof arguments[0] === "function") {
@@ -36,55 +36,7 @@ persistence.store.sqlite3_winrt.config = function(persistence, dbPath) {
db.close();
};
- function _executeSql(conn, sql, args) {
- var statement = conn.prepare(sql);
- if (args) {
- for (var i = 0; i < args.length; i++) {
- var arg = args[i];
- switch (typeof arg) {
- case 'number':
- if (arg===+arg && arg===(arg|0))
- statement.bindInt(i + 1, arg);
- else
- statement.bindDouble(i + 1, arg);
- break;
- case 'string':
- statement.bindText(i + 1, arg);
- break;
- default:
- break;
- }
- }
- }
-
- var result = [];
- while (statement.step() === SQLite3.ResultCode.row) {
- var row = {};
- for (var i = 0, len = statement.columnCount(); i < len; i++) {
- var name = statement.columnName(i);
- switch (statement.columnType(i)) {
- case SQLite3.Datatype.integer:
- row[name] = statement.columnInt(i);
- break;
- case SQLite3.Datatype.float:
- row[name] = statement.columnDouble(i);
- break;
- case SQLite3.Datatype.text:
- row[name] = statement.columnText(i);
- break;
- case SQLite3.Datatype.null:
- row[name] = null;
- break;
- }
- }
- result.push(row);
- }
-
- statement.close();
- return result;
- }
-
- function _transaction(conn){
+ function _transaction(db){
var that = {};
// TODO: add check for db opened or closed
that.executeSql = function(query, args, successFn, errorFn){
@@ -103,7 +55,7 @@ persistence.store.sqlite3_winrt.config = function(persistence, dbPath) {
console.log(query);
args && args.length > 0 && console.log(args.join(", "))
}
- var rows = _executeSql(conn, query, args);
+ var rows = db.execute(query, args);
if (successFn)
successFn(rows);
}

0 comments on commit e2a2739

Please sign in to comment.
Something went wrong with that request. Please try again.