Compare commits

..

No commits in common. "master" and "v1.2.1" have entirely different histories.

3 changed files with 8 additions and 22 deletions

View File

@ -1,6 +1,4 @@
'use strict';
/*global Promise*/
var PromiseA = Promise;
function lowerFirst(str) {
return str.charAt(0).toLowerCase() + str.substr(1);
@ -47,6 +45,7 @@ var searchConditions = {
function wrap(db, dir, dbsMap) {
// TODO if I put a failure right here,
// why doesn't the unhandled promise rejection fire?
var PromiseA = require('bluebird');
var promises = [];
var earr = [];
var debug = false;
@ -494,13 +493,7 @@ function wrap(db, dir, dbsMap) {
DB.save = function (data, oldId) {
if (!data[idnameCased] && !oldId) {
// NOTE saving the id both in the object and the id for now
data[idnameCased] = require('crypto').randomBytes(16).toString('hex').split('');
data[idnameCased].splice(8, 0, '-');
data[idnameCased].splice(8 + 1 + 4, 0, '-');
data[idnameCased].splice(8 + 1 + 4 + 1 + 4, 0, '-');
data[idnameCased].splice(8 + 1 + 4 + 1 + 4 + 1 + 4, 0, '-');
data[idnameCased][14] = 4; // TODO look at the mock uuid in the Go code I wrote
data[idnameCased] = data[idnameCased].join('');
data[idnameCased] = require('uuid').v4();
return DB.create(data[idnameCased], data).then(function (/*stats*/) {
//data._rowid = stats.id;
return data;
@ -683,14 +676,9 @@ function wrap(db, dir, dbsMap) {
});
}
function promisify(key) {
if ('function' !== typeof db[key] || /Async$/.test(key) || db[key + 'Async']) { return; }
db[key + 'Async'] = require('util').promisify(db[key]);
}
if (!db.__masterquest_init) {
db.__masterquest_init = true;
Object.keys(db).forEach(promisify);
['run', 'all'].forEach(promisify);
db = PromiseA.promisifyAll(db);
db.__masterquest_init = true;
db.escape = function (str) {
// TODO? literals for true,false,null

5
package-lock.json generated
View File

@ -1,5 +0,0 @@
{
"name": "masterquest-sqlite3",
"version": "1.3.0",
"lockfileVersion": 1
}

View File

@ -1,6 +1,6 @@
{
"name": "masterquest-sqlite3",
"version": "1.3.1",
"version": "1.2.1",
"description": "A NoSQL / SQLite3 Hybrid. All your indices are belong to us. Master Quest.",
"main": "lib/dbwrap",
"scripts": {
@ -13,5 +13,8 @@
"author": "AJ ONeal <coolaj86@gmail.com> (https://coolaj86.com/)",
"license": "(MIT OR Apache-2.0)",
"homepage": "https://git.coolaj86.com:coolaj86/masterquest-sqlite3.js",
"dependencies": {}
"dependencies": {
"bluebird": "^3.5.1",
"uuid": "^3.2.1"
}
}