replayOperations()function

replayOperations(provider: DBProvider<I, T>, operations: DBOperations<I, T>): Promise<void>
ParamType
providerDBProvider<I, T>
Provider to replay the operations onto. required
operationsDBOperations<I, T>
Operations to replay, in order. required
Return
Promise<void>

Replay a list of database operations onto a provider, re-issuing each one in order.

  • Writes re-issue as the corresponding item write — "add" replays as DBProvider.setItem() with the logged id, so the target keeps the same generated ids.
  • "get" reads apply what they observed — the item is set, or deleted when the read confirmed it absent. That's right for refreshing a mirror or cache, and wrong for an authoritative target, where an observed snapshot would overwrite newer data — replay only the writes there (see RecordingDBProvider.replayWrites()).
  • Operations re-issue as a sequence of awaited writes — the replay itself is not atomic.

Examples

await replayOperations(mirror, recording.operations);