see on GitHub

Revisions : Loading Revisions

There are a few methods that allow you to download revisions from a database:

  • session.Advanced.Revisions.GetFor
    • can be used to return all previous revisions for a specified document
  • session.Advanced.Revisions.GetMetadataFor
    • can be used to return metadata of all previous revisions for a specified document
  • session.Advanced.Revisions.Get
    • can be used to retrieve a revision(s) using a change vector(s)

GetFor

Syntax

List<T> GetFor<T>(string id, int start = 0, int pageSize = 25);

Parameters
id string document ID for which the revisions will be returned for
start int used for paging
pageSize int used for paging

Example

List<Order> orderRevisions = session
    .Advanced
    .Revisions
    .GetFor<Order>(
        id: "orders/1-A",
        start: 0,
        pageSize: 10);
List<Order> orderRevisions = await asyncSession
    .Advanced
    .Revisions
    .GetForAsync<Order>(
        id: "orders/1-A",
        start: 0,
        pageSize: 10);

GetMetadataFor

Syntax

List<MetadataAsDictionary> GetMetadataFor(string id, int start = 0, int pageSize = 25);

Parameters
id string document ID for which the revisions will be returned for
start int used for paging
pageSize int used for paging

Example

List<MetadataAsDictionary> orderRevisionsMetadata =
    session
        .Advanced
        .Revisions
        .GetMetadataFor(
            id: "orders/1-A",
            start: 0,
            pageSize: 10);
List<MetadataAsDictionary> orderRevisionsMetadata =
    await asyncSession
        .Advanced
        .Revisions
        .GetMetadataForAsync(
            id: "orders/1-A",
            start: 0,
            pageSize: 10);

Get

Syntax

T Get<T>(string changeVector);

Dictionary<string, T> Get<T>(IEnumerable<string> changeVectors);

Parameters
changeVector or changeVectors string or IEnumerable<string> one or many revision change vectors

Example

Order orderRevision =
    session
        .Advanced
        .Revisions
        .Get<Order>(orderRevisionChangeVector);
Order orderRevision =
    await asyncSession
        .Advanced
        .Revisions
        .GetAsync<Order>(orderRevisionChangeVector);