UNPKG

@x5e/gink

Version:

an eventually consistent database

58 lines (57 loc) 2.78 kB
import { Database } from "./Database"; import { Container } from "./Container"; import { Muid, AsOf, Meta } from "./typedefs"; export declare class Group extends Container { private constructor(); static get(database?: Database, muid?: Muid): Group; static create(database?: Database, meta?: Meta): Promise<Group>; /** * Includes a Muid or Container in the group. * @param key either a container or a Muid to include * @param change an optional bundler to put this change into * @returns a promise that resolves to the Muid for the inclusion */ include(key: Container, meta?: Meta): Promise<Muid>; /** * Excludes a Muid or Container from the group. * @param key either a Muid or container to exclude * @param change an optional bundler to put this in * @returns a promise that resolves to the Muid for the exclusion */ exclude(key: Container, meta?: Meta): Promise<Muid>; /** * This returns the number of inclusions only, NOT exclusions. * @returns how many containers are included in the group */ size(): Promise<number>; /** * Whether or not the given key is explicitly included in the group. * @param key either a Muid or container to check if it is included * @param asOf optional timestamp to look back to * @returns a promise that resolves to a boolean stating whether the key is explicitly included */ isIncluded(key: Muid | Container, asOf?: AsOf): Promise<boolean>; /** * Function to iterate over the containers in the group. * @param asOf optional timestamp to look back to * @returns an async iterator across all containers in the group */ getMembers(asOf?: AsOf): AsyncGenerator<Container, void, unknown>; /** * Dumps the contents of this group to a javascript array.Only includes explicitly included members. * useful for debugging and could also be used to export data by walking the tree * @param asOf effective time to get the dump for: leave undefined to get data as of the present * @returns an array containing Values (e.g. numbers, strings) and Containers (e.g. other Lists, Boxes, Directories) */ includedAsArray(asOf?: AsOf): Promise<Container[]>; reset(toTime?: AsOf, recurse?: any, meta?: Meta): Promise<void>; /** * Generates a JSON representation of the data in the group. * Mostly intended for demo/debug purposes. * @param indent true to pretty print (not yet implemented) * @param asOf optional timestamp to look back to * @param seen (internal use only! This prevents cycles from breaking things) * @returns a JSON string */ toJson(indent?: number | boolean, asOf?: AsOf, seen?: Set<string>): Promise<string>; }