MCPcopy Create free account
hub / github.com/bytebase/bytebase / getVersion

Method getVersion

backend/plugin/db/mongodb/sync.go:260–276  ·  view source on GitHub ↗

getVersion returns the version of mongod or mongos instance.

(ctx context.Context)

Source from the content-addressed store, hash-verified

258
259// getVersion returns the version of mongod or mongos instance.
260func (d *Driver) getVersion(ctx context.Context) (string, error) {
261 database := d.client.Database(bytebaseDefaultDatabase)
262 var commandResult bson.M
263 command := bson.D{{Key: "buildInfo", Value: 1}}
264 if err := database.RunCommand(ctx, command).Decode(&commandResult); err != nil {
265 return "", errors.Wrap(err, "cannot run buildInfo command")
266 }
267 version, ok := commandResult["version"]
268 if !ok {
269 return "", errors.New("cannot get version from buildInfo command result")
270 }
271 v, ok := version.(string)
272 if !ok {
273 return "", errors.New("cannot convert version to string")
274 }
275 return v, nil
276}
277
278// isDatabaseExist returns true if the database exists.
279func (d *Driver) isDatabaseExist(ctx context.Context, databaseName string) (bool, error) {

Callers 1

SyncInstanceMethod · 0.95

Implementers 15

MockDriverbackend/plugin/advisor/utils_for_tests
Driverbackend/plugin/db/bigquery/bigquery.go
Driverbackend/plugin/db/mongodb/mongodb.go
Driverbackend/plugin/db/trino/trino.go
Driverbackend/plugin/db/redshift/redshift.go
Driverbackend/plugin/db/oracle/oracle.go
Driverbackend/plugin/db/dynamodb/dynamodb.go
Driverbackend/plugin/db/cosmosdb/cosmosdb.go
Driverbackend/plugin/db/spanner/spanner.go
Driverbackend/plugin/db/mssql/mssql.go
Driverbackend/plugin/db/mysql/mysql.go
Driverbackend/plugin/db/pg/pg.go

Calls 1

DecodeMethod · 0.80

Tested by

no test coverage detected