API reference > @kontsedal/olas-core > Snapshot
Snapshot type
Returned by query.setData(...) or localCache.setData(...). Used bymutation.onMutate for optimistic-update rollback (spec §6.4).
rollback()restores the previous data state (and clears the "pending mutation" flag on the entry if no other snapshots are live). -finalize()commits the snapshot as the new truth — no rollback,hasPendingMutationsclears once all live snapshots on the entry are finalized or rolled back. The snapshots still live below it keep the commit: a later rollback of one restores its baseline with the committed change in it. The mutation runner calls this on success; user code rarely needs to.
Both are idempotent and mutually exclusive (calling one disables the other). Safe to call after the owning entry has been disposed.
Signature:
typescript
type Snapshot = {
rollback: () => void;
finalize: () => void;
};