Skip to content

Commit c81b8ff

Browse files
committed
tech feedback
1 parent 8d7212e commit c81b8ff

File tree

6 files changed

+26
-191
lines changed

6 files changed

+26
-191
lines changed

source/crud/delete.txt

Lines changed: 16 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -142,18 +142,9 @@ DeleteOne() Example: Full File
142142
.. include:: /includes/usage-examples/example-intro.rst
143143

144144
The following example is a fully runnable file that finds and deletes an
145-
existing document in the ``restaurants`` collection. Select the
146-
:guilabel:`Struct` or :guilabel:`bson.D` tab to see the corresponding code:
145+
existing document in the ``restaurants`` collection.
147146

148-
.. tabs::
149-
150-
.. tab:: Struct
151-
:tabid: structExample
152-
153-
The following code uses structs to define and delete a document in the
154-
``restaurants`` collection:
155-
156-
.. io-code-block::
147+
.. io-code-block::
157148
:copyable: true
158149

159150
.. input:: /includes/usage-examples/code-snippets/deleteOne.go
@@ -166,74 +157,30 @@ existing document in the ``restaurants`` collection. Select the
166157

167158
Documents deleted: 1
168159

169-
.. tab:: bson.D
170-
:tabid: bsonExample
171-
172-
The following code uses a bson.D type to define and delete a document in the
173-
``restaurants`` collection:
174-
175-
.. io-code-block::
176-
:copyable: true
177-
178-
.. input:: /includes/usage-examples/code-snippets/deleteOneBson.go
179-
:language: go
180-
:dedent:
181-
182-
.. output::
183-
:language: none
184-
:visible: false
185-
186-
Documents deleted: 1
187-
188160
DeleteMany() Example: Full File
189161
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
190162

191163
.. include:: /includes/usage-examples/example-intro.rst
192164

193-
The following example is a fully runnable file that finds and deletes multiple
194-
existing documents in the ``restaurants`` collection. Select the
195-
:guilabel:`Struct` or :guilabel:`bson.D` tab to see the corresponding code:
165+
The following example is a fully runnable file that performs the following
166+
actions on the ``restaurants`` collection:
196167

197-
.. tabs::
168+
- Matches and deletes documents where the ``cuisine`` field value is ``German``
169+
and the ``borough`` field value is ``Queens``
170+
- Deletes all matching documents
198171

199-
.. tab:: Struct
200-
:tabid: structExample
201-
202-
The following code uses structs to define and delete documents in the
203-
``restaurants`` collection:
204-
205-
.. io-code-block::
206-
:copyable: true
207-
208-
.. input:: /includes/usage-examples/code-snippets/deleteMany.go
209-
:language: go
210-
:dedent:
211-
212-
213-
.. output::
214-
:language: none
215-
:visible: false
216-
217-
Documents deleted: 6
218-
219-
.. tab:: bson.D
220-
:tabid: bsonExample
221-
222-
The following code uses a bson.D type to define and delete documents in the
223-
``restaurants`` collection:
224-
225-
.. io-code-block::
226-
:copyable: true
172+
.. io-code-block::
173+
:copyable: true
227174

228-
.. input:: /includes/usage-examples/code-snippets/deleteManyBson.go
229-
:language: go
230-
:dedent:
175+
.. input:: /includes/usage-examples/code-snippets/deleteMany.go
176+
:language: go
177+
:dedent:
231178

232-
.. output::
233-
:language: none
234-
:visible: false
179+
.. output::
180+
:language: none
181+
:visible: false
235182

236-
Documents deleted: 6
183+
Documents deleted: 6
237184

238185
Additional Information
239186
----------------------

source/includes/usage-examples/code-snippets/deleteMany.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,6 @@ type Restaurant struct {
2121
Cuisine string `bson:"cuisine"`
2222
}
2323

24-
// Creates a filter struct to specify the documents to delete
25-
type DeleteRestaurantFilter struct {
26-
Borough string `bson:"borough"`
27-
Cuisine string `bson:"cuisine"`
28-
}
29-
3024
func main() {
3125
if err := godotenv.Load(); err != nil {
3226
log.Println("No .env file found")
@@ -48,9 +42,9 @@ func main() {
4842
}()
4943

5044
coll := client.Database("sample_restaurants").Collection("restaurants")
51-
filter := DeleteRestaurantFilter{
52-
Borough: "Queens",
53-
Cuisine: "German",
45+
filter := bson.D{
46+
{"borough", "Queens"},
47+
{"cuisine", "German"},
5448
}
5549

5650
// Deletes all documents that have a "Borough" value of "Queens" and a "Cuisine" value of "German"

source/includes/usage-examples/code-snippets/deleteManyBson.go

Lines changed: 0 additions & 53 deletions
This file was deleted.

source/includes/usage-examples/code-snippets/deleteOne.go

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,12 @@ import (
1515

1616
// Defines a Restaurant struct as a model for documents in the "restaurants" collection
1717
type Restaurant struct {
18-
ID bson.ObjectID `bson:"_id"`
19-
Name string `bson:"name"`
20-
}
21-
22-
// Creates a filter struct to specify the document to delete
23-
type DeleteRestaurantFilter struct {
24-
Name string `bson:"name"`
18+
ID bson.ObjectID `bson:"_id"`
19+
Name string `bson:"name"`
20+
Cuisine string `bson:"cuisine,omitempty"`
21+
Address interface{} `bson:"address,omitempty"`
22+
Borough string `bson:"borough,omitempty"`
23+
Grades []interface{} `bson:"grades,omitempty"`
2524
}
2625

2726
func main() {
@@ -45,7 +44,7 @@ func main() {
4544
}()
4645

4746
coll := client.Database("sample_restaurants").Collection("restaurants")
48-
filter := DeleteRestaurantFilter{Name: "New Corner"}
47+
filter := bson.D{{"name", "New Corner"}}
4948

5049
// Deletes the first document that has a "name" value of "New Corner"
5150
result, err := coll.DeleteOne(context.TODO(), filter)

source/includes/usage-examples/code-snippets/deleteOneBson.go

Lines changed: 0 additions & 52 deletions
This file was deleted.

source/includes/usage-examples/code-snippets/insertOneBsonD.go

Whitespace-only changes.

0 commit comments

Comments
 (0)