getVersion
Get the current active database version
Definition
getVersion retrieves the active version for the current session. If no version has been set by the user using the setVersion
command, the current version from the database will be returned.
The getVersion command has the following form:
db.runCommand({
"getVersion" : <number>
})
The command accepts the following fields:
Field | Type | Mandatory |
---|---|---|
getVersion | number | yes |
Output
The returned document contains a subset of the following fields:
Field | Type | Description |
---|---|---|
ok | number | The status of the command. |
response | string | The response message. |
version | number | The version number which is current. |
status | number | The status of the version, indicating if the version is the current version or set by the user. |
Example
Version is current
The following command will get the current version :
> db.runCommand({getVersion:1});
{
"ok" : 1,
"response" : "The version is set to: 'current'",
"version" : NumberLong(5045),
"status" : "current"
}```
## Version has been set by the user:
```javascript
> db.runCommand({setVersion:2000});
{
"ok" : 1,
"response" : "The version has been set to: '2000'",
"version" : NumberLong(2000),
"status" : "userDefined"
}
> db.runCommand({getVersion:1});
{
"ok" : 1,
"response" : "The version is set to: '2000'",
"version" : NumberLong(2000),
"status" : "userDefined"
}
BulkLoad in progress:
> db.runCommand({getVersion:1});
{
"ok" : 1,
"response" : "The version is set to: '5046'",
"version" : NumberLong(5046),
"status" : "bulkLoad"
}
Updated over 5 years ago
What’s Next