getCheckpointIds
The getCheckpointIds
method returns an array of the checkpoint Ids
being managed by this Checkpoints
object.
getCheckpointIds(): CheckpointIds
returns | CheckpointIds | A |
---|
The returned CheckpointIds
array contains 'backward' checkpoint Ids
, the current checkpoint Id
(if present), and the 'forward' checkpointIds. Together, these are sufficient to understand the state of the Checkpoints
object and what movement is possible backward or forward through the checkpoint stack.
Example
This example creates a Store
, adds a Checkpoints
object, and then gets the Ids
of the checkpoints as it sets them and moves around the stack.
import {createCheckpoints, createStore} from 'tinybase';
const store = createStore().setTables({pets: {fido: {sold: false}}});
const checkpoints = createCheckpoints(store);
console.log(checkpoints.getCheckpointIds());
// -> [[], '0', []]
store.setCell('pets', 'fido', 'sold', true);
checkpoints.addCheckpoint('sale');
console.log(checkpoints.getCheckpointIds());
// -> [['0'], '1', []]
checkpoints.goBackward();
console.log(checkpoints.getCheckpointIds());
// -> [[], '0', ['1']]
checkpoints.goForward();
console.log(checkpoints.getCheckpointIds());
// -> [['0'], '1', []]
Since
v1.0.0