Skip to content

Commit

Permalink
Merge pull request #16 from hellofresh/patch/mongo-driver-1.0
Browse files Browse the repository at this point in the history
Bumped mongo driver to 1.0-rc1 to use new package structure
  • Loading branch information
vgarvardt authored Feb 25, 2019
2 parents 7ccfaf2 + 9e8734d commit a6ec287
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 57 deletions.
86 changes: 43 additions & 43 deletions Gopkg.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions Gopkg.toml
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@
name = "github.com/gofrs/uuid"
version = "3.2.0"

[[constraint]]
name = "github.com/mongodb/mongo-go-driver"
version = "0.3.0"

[prune]
go-tests = true
unused-packages = true

[[constraint]]
name = "go.mongodb.org/mongo-driver"
version = "v1.0.0-rc1"
11 changes: 6 additions & 5 deletions cmd/goengine/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import (
"github.com/hellofresh/goengine"
"github.com/hellofresh/goengine/mongodb"
"github.com/hellofresh/goengine/rabbit"
"github.com/mongodb/mongo-go-driver/mongo"
"github.com/mongodb/mongo-go-driver/mongo/options"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
)

func main() {
Expand All @@ -26,9 +26,10 @@ func main() {
}

goengine.Log("Connecting to the database", map[string]interface{}{"dsn": mongoDSN}, nil)
mongoClient, err := mongo.NewClientWithOptions(
mongoDSN,
options.Client().SetAppName("goengine"),
mongoClient, err := mongo.NewClient(
options.Client().
ApplyURI(mongoDSN).
SetAppName("goengine"),
)
if err != nil {
goengine.Log("Failed to create new Mongo mongoClient", nil, err)
Expand Down
10 changes: 5 additions & 5 deletions mongodb/eventstore.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@ import (

"github.com/hellofresh/goengine"
"github.com/hellofresh/goengine/reflection"
"github.com/mongodb/mongo-go-driver/bson"
"github.com/mongodb/mongo-go-driver/mongo"
"github.com/mongodb/mongo-go-driver/mongo/options"
"github.com/mongodb/mongo-go-driver/x/bsonx"
"go.mongodb.org/mongo-driver/bson"
"go.mongodb.org/mongo-driver/mongo"
"go.mongodb.org/mongo-driver/mongo/options"
"go.mongodb.org/mongo-driver/x/bsonx"
)

// MongoEvent represents an event on mongodb
Expand Down Expand Up @@ -163,7 +163,7 @@ func (s *EventStore) CountEventsFor(streamName goengine.StreamName, id string) (
ctx, cancel := s.cs.CountEventsFor()
defer cancel()

return s.mongoDB.Collection(string(streamName)).Count(ctx, bson.M{"aggregate_id": string(streamName)})
return s.mongoDB.Collection(string(streamName)).CountDocuments(ctx, bson.M{"aggregate_id": string(streamName)})
}

func (s *EventStore) createIndices(c *mongo.Collection) error {
Expand Down

0 comments on commit a6ec287

Please sign in to comment.