-
Type: Investigation
-
Resolution: Done
-
Priority: Major - P3
-
Affects Version/s: None
-
Component/s: None
-
None
-
Not Needed
This ticket removes two cursor methods from the legacy mongo shell.
- DBQuery.prototype.modifiers: The ‘modifiers()’ method could be used to add arbitrary options to the query. However, the modifiers were specified using an old syntax related to the no-longer-supported OP_QUERY wire protocol message. The ‘modifiers()’ method was part of an old version of the drivers CRUD API and does not appear in the current CRUD API spec (https://github.com/mongodb/specifications/blob/master/source/crud/crud.rst) or the current drivers find command spec (https://github.com/mongodb/specifications/blob/master/source/find_getmore_killcursors_commands.rst). Any code using the ‘modifiers()’ method should switch to using the explicit methods offered for setting options on a cursor.
- DBQuery.prototype.countReturn: The ‘countReturn()’ method would run a count comment without the skip or limit, and then apply the skip and limit on the client side. It had very few tests and was unneeded given that the skip and limit for a count command can be applied on the server side. Furthermore, the drivers spec for running count operations does not have any equivalent of ‘countReturn()’ to my knowledge. Any code using ‘countReturn()’ should be able to safely switch to using ‘count(true)’, where ‘true’ indicates that the skip and limit should be applied server-side.
These changes apply only to the legacy mongo shell, so there are no changes to mongosh.
Description of Linked Ticket
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.
- depends on
-
SERVER-68213 Stop generating an OP_QUERY-style query representation in the shell's find implementation
- Closed