API / @aionbuilders/nabu

CompactOptions

Type Stability: stable

Related guide: Persistence and sync →

Definition

TypeScript
import type { CompactOptions } from '@aionbuilders/nabu';
TypeScript
interface CompactOptions {
  onBeforeCompact?: (fullSnapshot: Uint8Array) => void | Promise<void>;
  retain: string | number;
}

Properties

Properties of CompactOptions
PropertyTypeDescription
onBeforeCompactoptional(fullSnapshot: Uint8Array) => void | Promise<void>

awaited with the COMPLETE snapshot (all the history) before anything is dropped; archive it. If it throws / rejects the compaction is ABORTED and nothing is lost.

retainstring | number

how much PAST history survives: a duration in ms, or a string <number><unit> with unit s, m, h, d or w ('30d', '12h'), or 0 = keep no past history. Required (there is no default that drops data).

Source: src/lib/persistence/history.js:11