Skip to content

Commit fa713b9

Browse files
mbroadstdaprahamian
authored andcommitted
chore: remove old unused count code
1 parent 34d56d7 commit fa713b9

File tree

1 file changed

+0
-76
lines changed

1 file changed

+0
-76
lines changed

lib/operations/collection_ops.js

Lines changed: 0 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -172,80 +172,6 @@ function checkForAtomicOperators(update) {
172172
}
173173
}
174174

175-
/**
176-
* Count the number of documents in the collection that match the query.
177-
*
178-
* @method
179-
* @param {Collection} a Collection instance.
180-
* @param {object} query The query for the count.
181-
* @param {object} [options] Optional settings. See Collection.prototype.count for a list of options.
182-
* @param {Collection~countCallback} [callback] The command result callback
183-
*/
184-
function count(coll, query, options, callback) {
185-
if (typeof options === 'function') (callback = options), (options = {});
186-
options = Object.assign({}, options);
187-
options.collectionName = coll.collectionName;
188-
189-
options.readPreference = resolveReadPreference(coll, options);
190-
191-
let cmd;
192-
try {
193-
cmd = buildCountCommand(coll, query, options);
194-
} catch (err) {
195-
return callback(err);
196-
}
197-
198-
executeCommand(coll.s.db, cmd, options, (err, result) => {
199-
if (err) return handleCallback(callback, err);
200-
handleCallback(callback, null, result.n);
201-
});
202-
}
203-
204-
/**
205-
* Build the count command.
206-
*
207-
* @method
208-
* @param {collectionOrCursor} an instance of a collection or cursor
209-
* @param {object} query The query for the count.
210-
* @param {object} [options] Optional settings. See Collection.prototype.count and Cursor.prototype.count for a list of options.
211-
*/
212-
function buildCountCommand(collectionOrCursor, query, options) {
213-
const skip = options.skip;
214-
const limit = options.limit;
215-
let hint = options.hint;
216-
const maxTimeMS = options.maxTimeMS;
217-
query = query || {};
218-
219-
// Final query
220-
const cmd = {
221-
count: options.collectionName,
222-
query: query
223-
};
224-
225-
// check if collectionOrCursor is a cursor by using cursor.s.numberOfRetries
226-
if (collectionOrCursor.s.numberOfRetries) {
227-
if (collectionOrCursor.s.options.hint) {
228-
hint = collectionOrCursor.s.options.hint;
229-
} else if (collectionOrCursor.s.cmd.hint) {
230-
hint = collectionOrCursor.s.cmd.hint;
231-
}
232-
decorateWithCollation(cmd, collectionOrCursor, collectionOrCursor.s.cmd);
233-
} else {
234-
decorateWithCollation(cmd, collectionOrCursor, options);
235-
}
236-
237-
// Add limit, skip and maxTimeMS if defined
238-
if (typeof skip === 'number') cmd.skip = skip;
239-
if (typeof limit === 'number') cmd.limit = limit;
240-
if (typeof maxTimeMS === 'number') cmd.maxTimeMS = maxTimeMS;
241-
if (hint) cmd.hint = hint;
242-
243-
// Do we have a readConcern specified
244-
decorateWithReadConcern(cmd, collectionOrCursor);
245-
246-
return cmd;
247-
}
248-
249175
/**
250176
* Create an index on the db and collection.
251177
*
@@ -1223,8 +1149,6 @@ function updateOne(coll, filter, update, options, callback) {
12231149
module.exports = {
12241150
bulkWrite,
12251151
checkForAtomicOperators,
1226-
count,
1227-
buildCountCommand,
12281152
createIndex,
12291153
createIndexes,
12301154
deleteMany,

0 commit comments

Comments
 (0)