From cddaba0b904de4c7f3c5967b2c84fb28ed698b3c Mon Sep 17 00:00:00 2001 From: Dan Aprahamian Date: Tue, 26 Jun 2018 17:59:40 -0400 Subject: [PATCH] feat(Collection): warn if callback is not function in find and findOne --- lib/collection.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/collection.js b/lib/collection.js index dfca7b5b3b..f9873359f4 100644 --- a/lib/collection.js +++ b/lib/collection.js @@ -274,6 +274,11 @@ const DEPRECATED_FIND_OPTIONS = ['maxScan', 'snapshot']; * @return {Cursor} */ Collection.prototype.find = function(query, options, callback) { + if (typeof callback === 'object') { + // TODO(MAJOR): throw in the future + console.warn('Third parameter to `find()` must be a callback or undefined'); + } + let selector = query; // figuring out arguments if (typeof callback !== 'function') { @@ -1003,6 +1008,11 @@ Collection.prototype.save = function(doc, options, callback) { * @return {Promise} returns Promise if no callback passed */ Collection.prototype.findOne = function(query, options, callback) { + if (typeof callback === 'object') { + // TODO(MAJOR): throw in the future + console.warn('Third parameter to `findOne()` must be a callback or undefined'); + } + if (typeof query === 'function') (callback = query), (query = {}), (options = {}); if (typeof options === 'function') (callback = options), (options = {}); query = query || {};