Skip to content

Commit 2a96116

Browse files
committed
tech feedback
1 parent d0e5687 commit 2a96116

File tree

3 files changed

+11
-101
lines changed

3 files changed

+11
-101
lines changed

source/crud/update/replace.txt

Lines changed: 9 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -131,47 +131,18 @@ collection:
131131
- Matches a document in which the value of ``name`` is "Rizzo's Fine Pizza"
132132
- Replaces the matched document with a new document
133133

134-
Select the :guilabel:`Struct` or :guilabel:`bson.D` tab to see the corresponding code:
135-
136-
.. tabs::
137-
138-
.. tab :: Struct
139-
:tabid: structExample
140-
141-
The following code uses structs to replace a document, in which the value of
142-
``name`` is "Rizzo's Fine Pizza", with a new document:
143-
144-
.. io-code-block::
145-
:copyable: true
146-
147-
.. input:: /includes/usage-examples/code-snippets/replace.go
148-
:language: go
149-
:dedent:
150-
151-
.. output::
152-
:language: none
153-
:visible: false
154-
155-
Number of documents replaced: 1
156-
157-
.. tab :: bson.D
158-
:tabid: bsonDExample
159-
160-
The following code uses a bson.D type to replace a document, in which the value of
161-
``name`` is "Rizzo's Fine Pizza", with a new document:
162-
163-
.. io-code-block::
164-
:copyable: true
134+
.. io-code-block::
135+
:copyable: true
165136

166-
.. input:: /includes/usage-examples/code-snippets/replaceBsonD.go
167-
:language: go
168-
:dedent:
137+
.. input:: /includes/usage-examples/code-snippets/replace.go
138+
:language: go
139+
:dedent:
169140

170-
.. output::
171-
:language: none
172-
:visible: false
141+
.. output::
142+
:language: none
143+
:visible: false
173144

174-
Number of documents replaced: 1
145+
Number of documents replaced: 1
175146

176147
Expected Result
177148
~~~~~~~~~~~~~~~

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

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"os"
99

1010
"github.com/joho/godotenv"
11+
"go.mongodb.org/mongo-driver/v2/bson"
1112
"go.mongodb.org/mongo-driver/v2/mongo"
1213
"go.mongodb.org/mongo-driver/v2/mongo/options"
1314
)
@@ -21,10 +22,6 @@ type Restaurant struct {
2122
Grades []interface{} `bson:"grades,omitempty"`
2223
}
2324

24-
type RestaurantNameFilter struct {
25-
Name string
26-
}
27-
2825
func main() {
2926
if err := godotenv.Load(); err != nil {
3027
log.Println("No .env file found")
@@ -46,7 +43,7 @@ func main() {
4643
}()
4744

4845
coll := client.Database("sample_restaurants").Collection("restaurants")
49-
filter := RestaurantNameFilter{Name: "Rizzo's Fine Pizza"}
46+
filter := bson.D{{"name", "Rizzo's Fine Pizza"}}
5047

5148
// Creates a new document containing "Name" and "Cuisine" fields
5249
replacement := Restaurant{Name: "Rizzo's Pizza", Cuisine: "Pizza/American"}

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

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

0 commit comments

Comments
 (0)