Skip to content

Commit 4431c9d

Browse files
authored
DOCSP-47800 Update bson primitive references (#423)
1 parent a399f8a commit 4431c9d

File tree

6 files changed

+13
-12
lines changed

6 files changed

+13
-12
lines changed

source/fundamentals/gridfs.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ The following example downloads a file and writes to a file buffer:
260260

261261
.. code-block:: go
262262

263-
id, err := primitive.ObjectIDFromHex("62f7bd54a6e4452da13b3e88")
263+
id, err := bson.ObjectIDFromHex("62f7bd54a6e4452da13b3e88")
264264
fileBuffer := bytes.NewBuffer(nil)
265265

266266
if _, err := bucket.DownloadToStream(id, fileBuffer); err != nil {
@@ -279,7 +279,7 @@ The following example downloads a file into memory and reads its contents:
279279

280280
.. code-block:: go
281281

282-
id, err := primitive.ObjectIDFromHex("62f7bd54a6e4452da13b3e88")
282+
id, err := bson.ObjectIDFromHex("62f7bd54a6e4452da13b3e88")
283283
downloadStream, err := bucket.OpenDownloadStream(id)
284284
if err != nil {
285285
panic(err)
@@ -303,7 +303,7 @@ The following example renames a file to ``"mongodbTutorial.zip"``:
303303

304304
.. code-block:: go
305305

306-
id, err := primitive.ObjectIDFromHex("62f7bd54a6e4452da13b3e88")
306+
id, err := bson.ObjectIDFromHex("62f7bd54a6e4452da13b3e88")
307307
if err := bucket.Rename(id, "mongodbTutorial.zip"); err != nil {
308308
panic(err)
309309
}
@@ -320,7 +320,7 @@ The following example deletes a file:
320320

321321
.. code-block:: go
322322

323-
id, err := primitive.ObjectIDFromHex("62f7bd54a6e4452da13b3e88")
323+
id, err := bson.ObjectIDFromHex("62f7bd54a6e4452da13b3e88")
324324
if err := bucket.Delete(id); err != nil {
325325
panic(err)
326326
}

source/includes/fundamentals/code-snippets/CRUD/retrieve.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99
"time"
1010

1111
"go.mongodb.org/mongo-driver/v2/bson"
12-
"go.mongodb.org/mongo-driver/v2/bson/primitive"
1312
"go.mongodb.org/mongo-driver/v2/mongo"
1413
"go.mongodb.org/mongo-driver/v2/mongo/options"
1514
)
@@ -118,7 +117,7 @@ func main() {
118117
fmt.Println("\nFind One by ObjectId:\n")
119118
{
120119
// begin objectid
121-
id, err := primitive.ObjectIDFromHex("65170b42b99efdd0b07d42de")
120+
id, err := bson.ObjectIDFromHex("65170b42b99efdd0b07d42de")
122121
if err != nil {
123122
panic(err)
124123
}

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,13 @@ import (
1010

1111
"github.com/joho/godotenv"
1212
"go.mongodb.org/mongo-driver/v2/bson"
13-
"go.mongodb.org/mongo-driver/v2/bson/primitive"
1413
"go.mongodb.org/mongo-driver/v2/mongo"
1514
"go.mongodb.org/mongo-driver/v2/mongo/options"
1615
)
1716

1817
// start-restaurant-struct
1918
type Restaurant struct {
20-
ID primitive.ObjectID `bson:"_id"`
19+
ID bson.ObjectID `bson:"_id"`
2120
Name string
2221
RestaurantId string `bson:"restaurant_id"`
2322
Cuisine string

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,13 @@ import (
1010

1111
"github.com/joho/godotenv"
1212
"go.mongodb.org/mongo-driver/v2/bson"
13-
"go.mongodb.org/mongo-driver/v2/bson/primitive"
1413
"go.mongodb.org/mongo-driver/v2/mongo"
1514
"go.mongodb.org/mongo-driver/v2/mongo/options"
1615
)
1716

1817
// start-restaurant-struct
1918
type Restaurant struct {
20-
ID primitive.ObjectID `bson:"_id"`
19+
ID bson.ObjectID `bson:"_id"`
2120
Name string
2221
RestaurantId string `bson:"restaurant_id"`
2322
Cuisine string

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ import (
99

1010
"github.com/joho/godotenv"
1111
"go.mongodb.org/mongo-driver/v2/bson"
12-
"go.mongodb.org/mongo-driver/v2/bson/primitive"
1312
"go.mongodb.org/mongo-driver/v2/mongo"
1413
"go.mongodb.org/mongo-driver/v2/mongo/options"
1514
)
@@ -36,7 +35,7 @@ func main() {
3635

3736
// begin updateone
3837
coll := client.Database("sample_restaurants").Collection("restaurants")
39-
id, _ := primitive.ObjectIDFromHex("5eb3d668b31de5d588f42a7a")
38+
id, _ := bson.ObjectIDFromHex("5eb3d668b31de5d588f42a7a")
4039
filter := bson.D{{"_id", id}}
4140

4241
// Creates instructions to add the "avg_rating" field to documents

source/whats-new.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ in the {+driver-short+} source code on GitHub.
9191
Learn more in the :ref:`golang-timeout-setting` section of the
9292
Connection Options guide.
9393

94+
- Removal of the ``bson/primitive`` package. This package is now merged with
95+
the ``bson`` package. To update your code, remove any ``bson/primitive``
96+
import statements and change any instance of ``primitive.ObjectID`` to
97+
``bson.ObjectId``.
98+
9499
This release includes the following improvements and fixes:
95100

96101
- Support for OpenID Connect (OIDC) authentication. To learn more, see

0 commit comments

Comments
 (0)