File tree 2 files changed +5
-5
lines changed
includes/usage-examples/code-snippets
2 files changed +5
-5
lines changed Original file line number Diff line number Diff line change @@ -55,17 +55,18 @@ func main() {
55
55
// is "Italian"
56
56
filter := bson.D {{"cuisine" , "Italian" }}
57
57
58
- // Retrieves documents that match the query filer
58
+ // Retrieves documents that match the query filter
59
59
cursor , err := coll .Find (context .TODO (), filter )
60
60
if err != nil {
61
61
panic (err )
62
62
}
63
- // end find
64
63
64
+ // Unpacks the cursor into a slice
65
65
var results []Restaurant
66
66
if err = cursor .All (context .TODO (), & results ); err != nil {
67
67
panic (err )
68
68
}
69
+ // end find
69
70
70
71
// Prints the results of the find operation as structs
71
72
for _ , result := range results {
Original file line number Diff line number Diff line change 4
4
Find Multiple Documents
5
5
=======================
6
6
7
- .. default-domain:: mongodb
8
-
9
7
You can find multiple documents in a collection by using the ``Find()``
10
8
method.
11
9
@@ -25,7 +23,8 @@ in the ``restaurants`` collection:
25
23
:dedent:
26
24
27
25
The 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:
29
28
30
29
.. literalinclude:: /includes/usage-examples/code-snippets/find.go
31
30
:start-after: begin find
You can’t perform that action at this time.
0 commit comments