@x5e/gink
Version:
an eventually consistent database
52 lines (51 loc) • 2.36 kB
TypeScript
import { Database } from "./Database";
import { Container } from "./Container";
import { Muid, AsOf, Meta } from "./typedefs";
export declare class PairSet extends Container {
private constructor();
static get(database?: Database, muid?: Muid): PairSet;
static create(database?: Database, meta?: Meta): Promise<PairSet>;
/**
* 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], meta?: Meta): 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], meta?: Meta): 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>;
reset(toTime?: AsOf, recurse?: any, meta?: Meta): 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>;
}