Skip to content

Commit 7090c39

Browse files
committed
quick cursor fix
1 parent 3bf0d78 commit 7090c39

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

src/cmap/wire_protocol/query.ts

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import { Document, pluckBSONSerializeOptions } from '../../bson';
77
import type { Server } from '../../sdam/server';
88
import type { ReadPreferenceLike } from '../../read_preference';
99
import type { FindOptions } from '../../operations/find';
10+
import { Explain } from '../../explain';
1011

1112
/** @internal */
1213
export interface QueryOptions extends CommandOptions {
@@ -62,7 +63,7 @@ export function query(
6263
}
6364

6465
function prepareFindCommand(server: Server, ns: string, cmd: Document) {
65-
let findCmd: Document = {
66+
const findCmd: Document = {
6667
find: collectionNamespace(ns)
6768
};
6869

@@ -146,12 +147,9 @@ function prepareFindCommand(server: Server, ns: string, cmd: Document) {
146147
if (cmd.collation) findCmd.collation = cmd.collation;
147148
if (cmd.readConcern) findCmd.readConcern = cmd.readConcern;
148149

149-
// If we have explain, we need to rewrite the find command
150-
// to wrap it in the explain command
151-
if (cmd.explain) {
152-
findCmd = {
153-
explain: findCmd
154-
};
150+
// TODO: Quick fix to make tests pass; will be updated during NODE-2853
151+
if (cmd.explain !== undefined) {
152+
findCmd.explain = Explain.fromOptions({ explain: cmd.explain });
155153
}
156154

157155
return findCmd;

0 commit comments

Comments
 (0)