fix syntax bug

This commit is contained in:
AJ ONeal 2016-03-23 03:38:59 +00:00
parent 422be49b1a
commit 2501c2fd4d
1 changed files with 11 additions and 8 deletions

View File

@ -228,16 +228,19 @@ function wrap(db, dir, dbsMap) {
DB.find = function (obj, params) { DB.find = function (obj, params) {
var err; var err;
var sql = 'SELECT * FROM \'' + tablename + '\' ';
var keys = obj && Object.keys(obj);
if (obj) {
Object.keys(obj).forEach(function (key) { Object.keys(obj).forEach(function (key) {
if (undefined === obj[key]) { if (undefined === obj[key]) {
err = new Error("'" + key + "' was `undefined'. For security purposes you must explicitly set the value to null or ''"); err = new Error("'" + key + "' was `undefined'. For security purposes you must explicitly set the value to null or ''");
} }
}); });
}
if (err) { if (err) {
return PromiseA.reject(err); return PromiseA.reject(err);
} }
var sql = 'SELECT * FROM \'' + tablename + '\' ';
var keys = obj && Object.keys(obj);
if (obj && keys.length) { if (obj && keys.length) {
sql += 'WHERE '; sql += 'WHERE ';
@ -255,7 +258,7 @@ function wrap(db, dir, dbsMap) {
} }
}); });
} }
else if (null !== obj1 || (params && !params.limit)) { else if (null !== obj || (params && !params.limit)) {
return PromiseA.reject(new Error("to find all you must explicitly specify find(null, { limit: <<int>> })")); return PromiseA.reject(new Error("to find all you must explicitly specify find(null, { limit: <<int>> })"));
} }