Skip to content

Commit

Permalink
remove shouldUseLegacyQuery
Browse files Browse the repository at this point in the history
  • Loading branch information
HanaPearlman committed Nov 19, 2020
1 parent 0bbcad3 commit 5c4cfd9
Showing 1 changed file with 1 addition and 8 deletions.
9 changes: 1 addition & 8 deletions src/cmap/wire_protocol/query.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export function query(
return callback(new MongoError(`command ${JSON.stringify(cmd)} does not return a cursor`));
}

if (shouldUseLegacyQuery(server, options)) {
if (maxWireVersion(server) < 4) {
const query = prepareLegacyFindQuery(server, ns, cmd, options);
const queryOptions = applyCommonQueryOptions(
{},
Expand Down Expand Up @@ -69,13 +69,6 @@ export function query(
command(server, ns, findCmd, commandOptions, callback);
}

// Typically, a legacy find query is used for wire versions prior to 4. However, for explain with
// find on wire versions between 3 and 4, we can't use a legacy find command.
function shouldUseLegacyQuery(server: Server, options: FindOptions): boolean {
const wireVersion = maxWireVersion(server);
return wireVersion <= 3 || (wireVersion < 4 && options.explain === undefined);
}

function prepareFindCommand(server: Server, ns: string, cmd: Document) {
const findCmd: Document = {
find: collectionNamespace(ns)
Expand Down

0 comments on commit 5c4cfd9

Please sign in to comment.