[DOCS-5987] Doc the find and getMore commands Created: 06/Aug/15  Updated: 11/Jan/17  Resolved: 20/Nov/15

Status: Closed
Project: Documentation
Component/s: Server
Affects Version/s: None
Fix Version/s: 01112017-cleanup

Type: Task Priority: Major - P3
Reporter: David Storch Assignee: Kay Kim (Inactive)
Resolution: Done Votes: 0
Labels: docs-3.1.8, docs-3.2
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Issue Links:
Depends
is depended on by CDRIVER-987 Link to server "find" command manual ... Closed
is depended on by DOCS-5590 find/getMore will no longer return pa... Closed
Documented
Related
related to DOCS-6141 Doc changes to the profiler format fo... Closed
is related to DOCS-5986 Remove documentation of shell's wrapp... Closed
is related to DOCS-6486 .readConcern() shell helper for db.co... Closed
Participants:
Days since reply: 8 years, 25 weeks ago

 Description   

We are introducing two new commands in 3.2 for the query subsystem: find and getMore. The shell and some drivers will use these commands to answer .find() operations against a 3.2 mongod or mongos. Although the syntax for .find() is largely unchanged, we should add documentation of the raw command parameters in the command reference pages.

For example, you could run a raw find command against a collection "c" like so:

db.runCommand({find: "c", filter: {a: {$gt: 3}}, sort: {b: -1}});



 Comments   
Comment by Jonathan Abrahams [ 26/Aug/15 ]

david.storch Thanks for your insight. A new ticket has been opened for the shell helper, DOCS-6103.

Comment by David Storch [ 26/Aug/15 ]

jonathan.abrahams, this ticket is not about documenting the db.collection.find() shell helper, but rather is about documenting the raw find command parameters. For context, in versions 3.0 and prior queries are transmitted to the server using the OP_QUERY/OP_REPLY protocol; the find and getMore commands constitute a new wire-level read protocol for version 3.2, built on top of the existing RPC-like commands mechanism. That's why you can now type,

db.foo.runCommand('find', {"readConcern": {"level": "majority"}})

or even

db.runCommand({find: "foo", filter: {a: 1}, readConcern: {level: "majority"}});

Keep in mind that a 3.2 shell connected to a 3.2 server will use the find/getMore commands read protocol automatically when you use the db.foo.find() shell method.

Anyway, to answer your original question, I don't think

db.foo.find({},{},99999999,0,1000,{"readConcern": {"level": "majority"}})

is valid syntax. The sixth argument to db.foo.find() is the "options" bit vector, used to set options like awaitData and slaveOk. I do not know our current plan for readConcern in the shell, i.e. whether we will have a helper and what syntax we will support. Mathias or Dannenberg might know better than me, as they have been more involved in the implementation of readConcern.

Hope that helps.

Best,
Dave

Comment by Jonathan Abrahams [ 26/Aug/15 ]

Question - Does this command permit the user to specify the readConcern?

db.foo.find({},{},99999999,0,1000,{"readConcern": {"level": "majority"}})

This is how it's done using runCommand:

db.foo.runCommand('find', {"readConcern": {"level": "majority"}})

Comment by Jonathan Abrahams [ 26/Aug/15 ]

Does this ticket include the shell helper which only documents query & projection? The other parameters are undocumented:

db.foo.find
function ( query , fields , limit , skip, batchSize, options )

Generated at Thu Feb 08 07:51:24 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.