Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
miilord committed Apr 29, 2024
1 parent b047d8d commit 0d43c8f
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,7 @@ type User struct {
Name string `bson:"name,omitempty" json:"name"`
Age int `bson:"age,omitempty" json:"age"`
}
```

Subsequently, the query is executed using mongo-go-driver:

```go
coll := db.Collection("users")
users := make([]*User, 0)
cursor, err := coll.Find(context.TODO(), bson.D{})
Expand All @@ -53,6 +49,12 @@ if err = cursor.All(context.TODO(), &users); err != nil {
In contrast, using modm can greatly simplify the process:

```go
type User struct {
DefaultField `bson:",inline"`
Name string `bson:"name,omitempty" json:"name"`
Age int `bson:"age,omitempty" json:"age"`
}

coll := NewRepo[*User](db.Collection("users"))
users, err := coll.Find(context.TODO(), bson.D{})
if err != nil {
Expand Down

0 comments on commit 0d43c8f

Please sign in to comment.