API / @aionbuilders/nabu

Recovery

Type Stability: stable

What happened when a stored document could not be read (ADR 010, theme 8). Exposed as nabu.persistence.recovery and given to the onRecover option, so the host can tell the user.

Related guide: Persistence and sync →

Definition

TypeScript
import type { Recovery } from '@aionbuilders/nabu';
TypeScript
interface Recovery {
  at: number;
  error: Error;
  kind: 'empty' | 'backup';
  quarantinedKey: string | null;
  quarantinedKeys: string[];
}

Properties

Properties of Recovery
PropertyTypeDescription
atnumber

epoch ms

errorError

why the latest stored snapshot was refused

kind'empty' | 'backup'

'backup': the document was restored from the PREVIOUS save (the last edits before the corrupted save are missing). 'empty': nothing readable was left, the editor started empty.

quarantinedKeystring | null

key (in the quarantine object store of the nabu database) of the unreadable record, which is never deleted. null if there was nothing to move (a missing record)

quarantinedKeysstring[]

every record moved aside (the backup too, when it was unreadable as well)

Source: src/lib/persistence/recovery.js:2