TinyBase logoTinyBase

getCheckpoint

The getCheckpoint method fetches the label for a checkpoint, if it had been provided at the time of the addCheckpoint method or set subsequently with the setCheckpoint method.

getCheckpoint(checkpointId: Id): undefined | string
TypeDescription
checkpointIdId

The Id of the checkpoint to get the label for.

returnsundefined | string

A string label for the requested checkpoint, an empty string if it was never set, or undefined if the checkpoint does not exist.

If the checkpoint has had no label provided, this method will return an empty string.

Examples

This example creates a Store, adds a Checkpoints object, and sets a checkpoint with a label, before retrieving it again.

const store = createStore().setTables({pets: {fido: {sold: false}}});

const checkpoints = createCheckpoints(store);
store.setCell('pets', 'fido', 'sold', true);
console.log(checkpoints.addCheckpoint('sale'));
// -> '1'

console.log(checkpoints.getCheckpoint('1'));
// -> 'sale'

This example creates a Store, adds a Checkpoints object, and sets a checkpoint without a label, setting it subsequently. A non-existent checkpoint return an undefined label.

const store = createStore().setTables({pets: {fido: {sold: false}}});

const checkpoints = createCheckpoints(store);
store.setCell('pets', 'fido', 'sold', true);
checkpoints.addCheckpoint();
console.log(checkpoints.getCheckpoint('1'));
// -> ''

checkpoints.setCheckpoint('1', 'sold');
console.log(checkpoints.getCheckpoint('1'));
// -> 'sold'

console.log(checkpoints.getCheckpoint('2'));
// -> undefined