File tree Expand file tree Collapse file tree 2 files changed +5
-5
lines changed
includes/usage-examples/code-snippets Expand file tree Collapse file tree 2 files changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -55,17 +55,18 @@ func main() {
5555 // is "Italian"
5656 filter := bson.D {{"cuisine" , "Italian" }}
5757
58- // Retrieves documents that match the query filer
58+ // Retrieves documents that match the query filter
5959 cursor , err := coll .Find (context .TODO (), filter )
6060 if err != nil {
6161 panic (err )
6262 }
63- // end find
6463
64+ // Unpacks the cursor into a slice
6565 var results []Restaurant
6666 if err = cursor .All (context .TODO (), & results ); err != nil {
6767 panic (err )
6868 }
69+ // end find
6970
7071 // Prints the results of the find operation as structs
7172 for _ , result := range results {
Original file line number Diff line number Diff line change 44Find Multiple Documents
55=======================
66
7- .. default-domain:: mongodb
8-
97You can find multiple documents in a collection by using the ``Find()``
108method.
119
@@ -25,7 +23,8 @@ in the ``restaurants`` collection:
2523 :dedent:
2624
2725The following example matches documents in the ``restaurants`` collection
28- in which the ``cuisine`` is "Italian", returning all documents matched:
26+ in which the ``cuisine`` is ``"Italian"``, returns a cursor that
27+ references the matched documents, then unpacks the documents into a slice:
2928
3029.. literalinclude:: /includes/usage-examples/code-snippets/find.go
3130 :start-after: begin find
You can’t perform that action at this time.
0 commit comments