Skip to content

DOCSP-40206: find usageex edit #365

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions source/includes/usage-examples/code-snippets/find.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,17 +55,18 @@ func main() {
// is "Italian"
filter := bson.D{{"cuisine", "Italian"}}

// Retrieves documents that match the query filer
// Retrieves documents that match the query filter
cursor, err := coll.Find(context.TODO(), filter)
if err != nil {
panic(err)
}
// end find

// Unpacks the cursor into a slice
var results []Restaurant
if err = cursor.All(context.TODO(), &results); err != nil {
panic(err)
}
// end find

// Prints the results of the find operation as structs
for _, result := range results {
Expand Down
5 changes: 2 additions & 3 deletions source/usage-examples/find.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
Find Multiple Documents
=======================

.. default-domain:: mongodb

You can find multiple documents in a collection by using the ``Find()``
method.

Expand All @@ -25,7 +23,8 @@ in the ``restaurants`` collection:
:dedent:

The following example matches documents in the ``restaurants`` collection
in which the ``cuisine`` is "Italian", returning all documents matched:
in which the ``cuisine`` is ``"Italian"``, returns a cursor that
references the matched documents, then unpacks the documents into a slice:

.. literalinclude:: /includes/usage-examples/code-snippets/find.go
:start-after: begin find
Expand Down
Loading