Skip to content

Commit cddaba0

Browse files
committed
feat(Collection): warn if callback is not function in find and findOne
1 parent 36c591d commit cddaba0

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/collection.js

+10
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,11 @@ const DEPRECATED_FIND_OPTIONS = ['maxScan', 'snapshot'];
274274
* @return {Cursor}
275275
*/
276276
Collection.prototype.find = function(query, options, callback) {
277+
if (typeof callback === 'object') {
278+
// TODO(MAJOR): throw in the future
279+
console.warn('Third parameter to `find()` must be a callback or undefined');
280+
}
281+
277282
let selector = query;
278283
// figuring out arguments
279284
if (typeof callback !== 'function') {
@@ -1003,6 +1008,11 @@ Collection.prototype.save = function(doc, options, callback) {
10031008
* @return {Promise} returns Promise if no callback passed
10041009
*/
10051010
Collection.prototype.findOne = function(query, options, callback) {
1011+
if (typeof callback === 'object') {
1012+
// TODO(MAJOR): throw in the future
1013+
console.warn('Third parameter to `findOne()` must be a callback or undefined');
1014+
}
1015+
10061016
if (typeof query === 'function') (callback = query), (query = {}), (options = {});
10071017
if (typeof options === 'function') (callback = options), (options = {});
10081018
query = query || {};

0 commit comments

Comments
 (0)