The implementation of DBQuery in the shell currently will internally construct an OP_QUERY-style object. Let's take the following simple example query:
const cursor = db.myCollection.find({x: 3}).sort({y: 1}).hint({x: 1});
The cursor object is a DBQuery. The _query property of the DBQuery will be a JS object that looks like this:
{query: {x: 3}, orderby: {y: 1}, $hint: {x: 1}}
This is the format that was formerly accepted in the query field of an OP_QUERY wire protocol message. However, OP_QUERY was deprecated in MongoDB 5.0 and removed in MongoDB 5.1. The OP_QUERY-style payload is summarily converted into a find command by the _convertToCommand() helper.
These shenanigans used to be necessary when the mongo shell supported by OP_QUERY legacy reads and the find command. But now that OP_QUERY reads are a thing of the past, the shell code should be simplified to construct the find command format directly.
- is depended on by
-
COMPASS-6036 Investigate changes in SERVER-68213: Stop generating an OP_QUERY-style query representation in the shell's find implementation
- Closed
- is related to
-
SERVER-20770 Consolidate the two code paths for running find commands in the mongo shell
- Backlog