Find a Document
On this page
You can retrieve a document by using the Find()
method on a collection object.
Example
Find a Document by Using Builders
The following example uses Builders
to find a document in the restaurants
collection that has a name
field with a value of "Bagels N Buns".
Select the Asynchronous or Synchronous tab to see the corresponding code.
Find a Document by Using LINQ
The following example uses LINQ to find a document in the restaurants
collection that has a name
field with a value of "Bagels N Buns".
Select the Asynchronous or Synchronous tab to see the corresponding code.
Expected Result
Running any of the preceding full examples prints results similar to the following:
{ "_id" : ObjectId("5eb3d668b31de5d588f42950"), "name" : "Bagels N Buns", "restaurant_id" : "40363427", "cuisine" : "Delicatessen", "address" : {...}, "borough" : "Staten Island", "grades" : [...] }
Additional Information
To learn more about retrieving documents, see the Retrieve Data guide.
To learn more about using builders, see Operations with Builders.
To learn how to find a document using LINQ, see LINQ.