Skip to main content

Home > git-documentdb > GitDocumentDB > getOldRevision

GitDocumentDB.getOldRevision() method#

Get an old revision of a document

Signature:
getOldRevision(_id: string, revision: number, historyOptions?: HistoryOptions): Promise<JsonDoc | undefined>;

Parameters#

ParameterTypeDescription
_idstring_id is a file path whose extension is omitted.
revisionnumberSpecify a number to go back to old revision. Default is 0. See GitDocumentDB.getHistory() for the array of revisions.
historyOptionsHistoryOptionsThe array of revisions is filtered by HistoryOptions.filter.
Returns:

Promise<JsonDoc | undefined>

Remarks#

  • undefined if a specified document does not exist or it is deleted.

  • This is an alias of GitDocumentDB#rootCollection.getOldRevision()

Example#

db.getOldRevision(_id, 0); // returns the latest document.
db.getOldRevision(_id, 2); // returns a document two revisions older than the latest.

Exceptions#

Err.DatabaseClosingError

Err.InvalidJsonObjectError