Get Revisions Operation



Get all revisions

// Define the get revisions operation, pass the document id
const getRevisionsOp = new GetRevisionsOperation("Companies/1-A");

// Execute the operation by passing it to operations.send
const revisions = await documentStore.operations.send(getRevisionsOp);

// The revisions info:
const allRevisions = revisions.results;        // All the revisions
const revisionsCount = revisions.totalResults; // Total number of revisions

Paging results

  • Get and process revisions, one page at a time:

const parameters = {
    start: 0,
    pageSize: 100
};

while (true)
{
    // Execute the get revisions operation
    // Pass parameters with document id, start & page size
    const revisions = await documentStore.operations.send(
        new GetRevisionsOperation("Companies/1-A", parameters));
    
    {
        // Process the retrieved revisions here
    }

    if (revisions.results.length < parameters.pageSize)
        break; // No more revisions to retrieve

    // Increment 'start' by page-size, to get the "next page" in next iteration
    parameters.start += parameters.pageSize;
}

Syntax

// Available overloads:
const getRevisionsOp = new GetRevisionsOperation(id);
const getRevisionsOp = new GetRevisionsOperation(id, parameters);
Parameter Type Description
id string Document ID for which to get revisions
parameters object An object that wraps start and pageSize (see below)

// The parameters object
{
    start,   // Revision number to start from
    pageSize // Number of revisions to get
}
Return value of store.operations.send(getRevisionsOp)
RevisionsResult Object with revisions results

class RevisionsResult
{
    results;      // The retrieved revisions
    totalResults; // Total number of revisions that exist for the document
}