Skip to content
Snippets Groups Projects
Commit ff84e028 authored by André Sterba's avatar André Sterba
Browse files

Fix mongo deprecations

parent e40853bc
No related branches found
No related tags found
1 merge request!495Update mongo driver and fix deprecations
......@@ -20,16 +20,11 @@ const (
// GetMongoConnection Retrieves a client to the MongoDB.
func GetMongoConnection() (*mongo.Client, context.Context, context.CancelFunc) {
mongoConnection := config.DatabaseConnection
client, err := mongo.NewClient(options.Client().ApplyURI(mongoConnection))
if err != nil {
log.Printf("Failed to create client: %v", err)
}
ctx, cancel := context.WithTimeout(context.Background(), connectTimeout*time.Second)
err = client.Connect(ctx)
client, err := mongo.Connect(ctx, options.Client().ApplyURI(mongoConnection))
if err != nil {
log.Printf("Failed to connect to cluster: %v", err)
log.Printf("Failed to create client: %v", err)
}
// Force a connection to verify our connection string
......
......@@ -171,7 +171,8 @@ func (s *DatabaseNetworkElementStore) Update(networkElementToUpdate networkeleme
}()
// 1. Start Transaction
wcMajority := writeconcern.New(writeconcern.WMajority())
wcMajority := writeconcern.Majority()
wcMajorityCollectionOpts := options.Collection().SetWriteConcern(wcMajority)
userCollection := client.Database(database.DatabaseName).Collection(s.storeName, wcMajorityCollectionOpts)
......
......@@ -189,7 +189,7 @@ func (s *DatabaseUserStore) Update(userToUpdate rbac.User) (err error) {
}()
// 1. Start Transaction
wcMajority := writeconcern.New(writeconcern.WMajority())
wcMajority := writeconcern.Majority()
wcMajorityCollectionOpts := options.Collection().SetWriteConcern(wcMajority)
userCollection := client.Database(database.DatabaseName).Collection(s.userStoreName, wcMajorityCollectionOpts)
......
......@@ -181,7 +181,7 @@ func (s *DatabaseNodeStore) Update(node Node) (err error) {
}()
// 1. Start Transaction
wcMajority := writeconcern.New(writeconcern.WMajority())
wcMajority := writeconcern.Majority()
wcMajorityCollectionOpts := options.Collection().SetWriteConcern(wcMajority)
nodeCollection := client.Database(database.DatabaseName).Collection(s.storeName, wcMajorityCollectionOpts)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment