mirror of
https://github.com/gofiber/storage.git
synced 2025-10-05 08:37:10 +08:00
Replace NewClient with mongo.Connect
This commit is contained in:

committed by
GitHub

parent
4b89c87336
commit
9190b12c2e
@@ -53,11 +53,13 @@ func New(config ...Config) *Storage {
|
||||
}
|
||||
|
||||
// Set mongo options
|
||||
opt := options.Client()
|
||||
opt.ApplyURI(dsn)
|
||||
opt := options.Client().ApplyURI(dsn)
|
||||
|
||||
// Create mongo client
|
||||
client, err := mongo.NewClient(opt)
|
||||
// Create and connect the mongo client in one step
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second)
|
||||
defer cancel()
|
||||
|
||||
client, err := mongo.Connect(ctx, opt)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
Reference in New Issue
Block a user