Permalink
Browse files

fix:  query  find with no callback

  • Loading branch information...
XadillaX committed Oct 20, 2016
1 parent bc67f87 commit 8cf2d79efedbf25b0f82caf90b407c18efc6ac5c
Showing with 11 additions and 9 deletions.
  1. +11 −9 lib/query.js
@@ -201,17 +201,19 @@ class ToshihikoQuery {
* @returns {Promise} the promise object
*/
find(callback, toJSON, options) {
if(typeof callback !== "function") {
options = toJSON;
toJSON = callback;
callback = emptyFunc;
}
if(typeof toJSON === "object") {
options = toJSON;
toJSON = false;
for(let i = 0; i < arguments.length; i++) {
switch(typeof arguments[i]) {
case "function": callback = arguments[i]; break;
case "boolean": toJSON = arguments[i]; break;
case "object": options = arguments[i]; break;
default: break;
}
}

if(typeof callback !== "function") callback = emptyFunc;
if(typeof toJSON !== "boolean") toJSON = false;
if(typeof options !== "object") options = {};
options = options || {};
if(undefined === callback) callback = emptyFunc;

callback = common.promisify(callback);
const self = this;

0 comments on commit 8cf2d79

Please sign in to comment.