mirror of
https://github.com/crawlab-team/crawlab.git
synced 2026-01-21 17:21:09 +01:00
refactor: Update models to use DatabaseV2 instead of DataSourceV2
This commit is contained in:
@@ -111,28 +111,13 @@ func getMongoClientV2(ctx context.Context, ds *models2.DatabaseV2) (c *mongo2.Cl
|
||||
// options
|
||||
var opts []mongo.ClientOption
|
||||
opts = append(opts, mongo.WithContext(ctx))
|
||||
opts = append(opts, mongo.WithUri(ds.Url))
|
||||
opts = append(opts, mongo.WithUri(ds.URI))
|
||||
opts = append(opts, mongo.WithHost(ds.Host))
|
||||
opts = append(opts, mongo.WithPort(ds.Port))
|
||||
opts = append(opts, mongo.WithDb(ds.Database))
|
||||
opts = append(opts, mongo.WithUsername(ds.Username))
|
||||
opts = append(opts, mongo.WithPassword(ds.Password))
|
||||
|
||||
// extra
|
||||
if ds.Extra != nil {
|
||||
// auth source
|
||||
authSource, ok := ds.Extra["auth_source"]
|
||||
if ok {
|
||||
opts = append(opts, mongo.WithAuthSource(authSource))
|
||||
}
|
||||
|
||||
// auth mechanism
|
||||
authMechanism, ok := ds.Extra["auth_mechanism"]
|
||||
if ok {
|
||||
opts = append(opts, mongo.WithAuthMechanism(authMechanism))
|
||||
}
|
||||
}
|
||||
|
||||
// client
|
||||
return mongo.GetMongoClient(opts...)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user