listVersions

List versions in the database

Definition

listVersions returns an array of version information matching a date range filter.

The listVersions command has the following format:

{
    "listVersions": {
          "startDate": <ISODate>,
          "endDate": <ISODate>,
          "limit": <number>,
          "sortDirection": <number>
     }
}

The command accepts the following fields:

FieldTypeMandatory
startDateISODateno
endDateISODateno
limitnumberno
sortDirectionnumberno

Output

The returned document contains a array of the following fields:

FieldTypeDescription
oknumberThe status of the command.
versionsarrayThe list of versions.
versions.versionnumberThe version number.
versions.statusstringStatus of the version
versions.effectiveDateISODateThe effective date for the version. This is the date that all ProvenDB processing completed.

Examples

Get the version in effect this time yesterday

// Create a ISODate for one day ago (24*60*60*1000 is milliseconds in 24 hours)
mongo>var yesterday = new Date(new Date() - 24 * 3600 * 1000);
mongo>db.runCommand({
...   listVersions: { endDate: yesterday, limit: 1, sortDirection: -1 }
... });
{
	"ok" : 1,
	"versions" : [
		{
			"version" : NumberLong(5046),
			"status" : "Ended",
			"effectiveDate" : ISODate("2019-03-19T05:52:39Z")
		}
	]
}

What’s Next