UNPKG

@x5e/gink

Version:

an eventually consistent database

55 lines (54 loc) 3.07 kB
import { Bundler } from "./Bundler"; import { Value, ScalarKey, Muid, AsOf } from "./typedefs"; import { Deletion } from "./Deletion"; import { Inclusion } from "./Inclusion"; import { Database } from "./Database"; import { Behavior } from "./builders"; import { Addressable } from "./Addressable"; export declare class Container extends Addressable { readonly database: Database; readonly behavior: Behavior; protected static readonly DELETION: Deletion; protected static readonly INCLUSION: Inclusion; protected constructor(database: Database, address: Muid, behavior: Behavior); toString(): string; toJson(indent?: number | boolean, asOf?: AsOf, seen?: Set<string>): Promise<string>; setName(name: string, bundlerOrComment?: Bundler | string): Promise<Muid>; getName(asOf?: AsOf): Promise<Value | Container>; clear(purge?: boolean, bundlerOrComment?: Bundler | string): Promise<Muid>; /** * Reset this Container to a previous time. If no time is specified, the container will * be cleared. * @param args Optional arguments, including: * @argument toTime Optional time to reset to. If absent, the container will be cleared. * @argument bundlerOrComment Bundler to add this change to, string to add a comment to a * new bundle, or empty to apply immediately. * @argument skipProperties If true, do not reset properties of this container. By default, * all properties associated with this container will be reset to the time specified in toTime. * @argument recurse Recursively reset all child containers held by this container at reset time? * @argument seen A Set of seen container muids (in string form) to prevent infinite recursion. * Primarily for internal use, but could be used to prevent specific containers from being reset. */ reset(args?: { toTime?: AsOf; bundlerOrComment?: Bundler | string; skipProperties?: boolean; recurse?: boolean; seen?: Set<string>; }): Promise<void>; size(): Promise<number>; /** * * @param key If absent, create a boxed entry, if KeyType, set a key in entry, if true, create a list entry * @param value What the container ought to contain (an immediate Value, a reference, or a deletion) * @param bundlerOrComment Bundler to add this change to, or empty to apply immediately. * @returns a promise the resolves to the muid of the change */ protected addEntry(key?: ScalarKey | Addressable | [Addressable, Addressable] | Muid | [Muid, Muid], value?: Value | Deletion | Inclusion, bundlerOrComment?: Bundler | string): Promise<Muid>; /** * Reset the properties associated with this container to a previous time. * @param toTime optional timestamp to reset to. If not provided, the properties will be deleted. * @param bundlerOrComment optional bundler to add this change to, or a string to add a comment to a new bundle. */ resetProperties(toTime?: AsOf, bundlerOrComment?: Bundler | string): Promise<void>; }