UNPKG

@x5e/gink

Version:

an eventually consistent database

72 lines (71 loc) 3.42 kB
import { Database } from "./Database"; import { Container } from "./Container"; import { Muid, AsOf } from "./typedefs"; import { Bundler } from "./Bundler"; import { ContainerBuilder } from "./builders"; export declare class PairSet extends Container { constructor(database: Database, address: Muid, containerBuilder?: ContainerBuilder); /** * Includes a pair of Muids or Containers in the pair set. * @param key a pair of either containers or Muids 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, Container], change?: Bundler | string): Promise<Muid>; /** * Excludes a pair of Muids or Containers in the pair set. * @param key a pair of either containers or Muids to include * @param change an optional bundler to put this change into * @returns a promise that resolves to the Muid for the exclusion */ exclude(key: [Container, Container], change?: Bundler | string): Promise<Muid>; /** * If the pair set has a key or not. * @param key array of 2 muids or containers * @param asOf optional timestamp to look back to * @returns a promise that resolves to a boolean, true if the key is included, false if not */ contains(key: [Muid | Container, Muid | Container], asOf?: AsOf): Promise<boolean>; /** * * @param args Optional arguments, including: * @argument toTime Optional time to reset to. If absent, the container will be cleared. * @argument bundlerOrComment Optional bundler or comment to add this change to * @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 NOTE: THIS FLAG IS IGNORED. Recursive reset for Inclusion-based containers * is not yet implemented, but this arg needs to be accepted for other containers recursively * resetting this one. * @argument seen NOTE: THIS FLAG IS IGNORED. Recursive reset for Inclusion-based containers * is not yet implemented, but this arg needs to be accepted for other containers recursively * resetting this one. */ reset(args?: { toTime?: AsOf; bundlerOrComment?: Bundler | string; skipProperties?: boolean; recurse?: boolean; seen?: Set<string>; }): Promise<void>; /** * The number of items in the pair set. * @param asOf optional timestamp to look back to * @returns a promise that resolves to the number of entries */ size(asOf?: AsOf): Promise<number>; /** * All of the pairs in the Pair Set as a set * @param asOf optional timestamp to look back to * @returns a promise that resolves to a set of pairs [Muid, Muid] */ getPairs(asOf?: AsOf): Promise<Set<Array<Muid>>>; /** * Generates a JSON representation of the data in the pair set. * 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>; }