Skip to content

Commit

Permalink
Add note about bson import to README (mongodb#451)
Browse files Browse the repository at this point in the history
  • Loading branch information
weienwong authored Jul 16, 2020
1 parent ec38fc2 commit f88ea24
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,19 @@ res, err := collection.InsertOne(ctx, bson.M{"name": "pi", "value": 3.14159})
id := res.InsertedID
```

To use `bson.M`, you will need to add `"go.mongodb.org/mongo-driver/bson"` to your imports.

Your import statement should now look like this:

```go
import (
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
"go.mongodb.org/mongo-driver/mongo/readpref"
)
```

Several query methods return a cursor, which can be used like this:

```go
Expand Down

0 comments on commit f88ea24

Please sign in to comment.