Skip to content

Commit 6ff39ef

Browse files
committedNov 7, 2015
fix; unhandled rejection using Query.then() (Fix #3543)
1 parent 8cccafb commit 6ff39ef

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
 

‎lib/query.js

+14
Original file line numberDiff line numberDiff line change
@@ -2134,6 +2134,20 @@ Query.prototype.exec = function exec(op, callback) {
21342134
});
21352135
};
21362136

2137+
/**
2138+
* Executes the query returning a `Promise` which will be
2139+
* resolved with either the doc(s) or rejected with the error.
2140+
*
2141+
* @param {Function} [resolve]
2142+
* @param {Function} [reject]
2143+
* @return {Promise}
2144+
* @api public
2145+
*/
2146+
2147+
Query.prototype.then = function(resolve, reject) {
2148+
return this.exec().then(resolve, reject);
2149+
}
2150+
21372151
/**
21382152
* Finds the schema for `path`. This is different than
21392153
* calling `schema.path` as it also resolves paths with

0 commit comments

Comments
 (0)
Please sign in to comment.