File tree Expand file tree Collapse file tree 3 files changed +12
-105
lines changed
includes/usage-examples/code-snippets Expand file tree Collapse file tree 3 files changed +12
-105
lines changed Original file line number Diff line number Diff line change @@ -129,51 +129,20 @@ collection:
129
129
- Matches documents in which the value of the ``cuisine`` field is ``"Tapas"``
130
130
- Returns distinct values of the ``borough`` field from the matched documents
131
131
132
- .. tabs::
133
-
134
- .. tab:: Struct
135
- :tabid: structExample
136
-
137
- The following code uses a struct to retrieve distinct values of the
138
- ``borough`` field for documents in the ``restaurants`` collection that match
139
- the specified filter:
140
-
141
- .. io-code-block::
142
- :copyable: true
143
-
144
- .. input:: /includes/usage-examples/code-snippets/distinct.go
145
- :language: go
146
- :dedent:
147
-
148
- .. output::
149
- :language: none
150
- :visible: false
151
-
152
- Brooklyn
153
- Manhattan
154
- Queens
155
-
156
- .. tab:: bson.D
157
- :tabid: bsonDExample
158
-
159
- The following code uses a bson.D type to retrieve distinct values of the
160
- ``borough`` field for documents in the ``restaurants`` collection that match
161
- the specified filter:
162
-
163
- .. io-code-block::
164
- :copyable: true
132
+ .. io-code-block::
133
+ :copyable: true
165
134
166
- .. input:: /includes/usage-examples/code-snippets/distinctBsonD .go
167
- :language: go
168
- :dedent:
135
+ .. input:: /includes/usage-examples/code-snippets/distinct .go
136
+ :language: go
137
+ :dedent:
169
138
170
- .. output::
171
- :language: none
172
- :visible: false
139
+ .. output::
140
+ :language: none
141
+ :visible: false
173
142
174
- Brooklyn
175
- Manhattan
176
- Queens
143
+ Brooklyn
144
+ Manhattan
145
+ Queens
177
146
178
147
Additional Information
179
148
----------------------
Original file line number Diff line number Diff line change @@ -23,11 +23,6 @@ type Restaurant struct {
23
23
Grades interface {}
24
24
}
25
25
26
- // Creates a filter struct to use for the query
27
- type RestaurantCuisineFilter struct {
28
- Cuisine string
29
- }
30
-
31
26
func main () {
32
27
if err := godotenv .Load (); err != nil {
33
28
log .Println ("No .env file found" )
@@ -50,7 +45,7 @@ func main() {
50
45
51
46
// Filters the collection for documents where the value of cuisine is "Tapas"
52
47
coll := client .Database ("sample_restaurants" ).Collection ("restaurants" )
53
- filter := RestaurantCuisineFilter { Cuisine : "Tapas" }
48
+ filter := bson. D {{ "cuisine" , "Tapas" } }
54
49
55
50
// Retrieves the distinct values of the "borough" field in documents
56
51
// that match the filter
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments