UNPKG

@x5e/gink

Version:

an eventually consistent database

38 lines (37 loc) 1.88 kB
import { Addressable } from "./Addressable"; import { Database } from "./Database"; import { AsOf, EdgeData, Muid, Value, Timestamp } from "./typedefs"; import { Vertex } from "./Vertex"; import { EdgeType } from "./EdgeType"; import { Bundler } from "./Bundler"; export declare class Edge extends Addressable { readonly database: Database; private source; private target; private action; private value?; constructor(database: Database, address: Muid, data: EdgeData); private setFromEdgeData; static load(database: Database, address: Muid): Promise<Edge>; getSourceVertex(): Vertex; getTargetVertex(): Vertex; getEdgeType(): EdgeType; getValue(): Value | undefined; /** * NOTE: If this edge has been removed, or if its edgeType has been reset, this method will ALWAYS return false. * If its edgeType has been reset, it has been replaced with a new edge that has the exact same source, target, value, * and properties. Check getEdgesTo and getEdgesFrom on the source and target vertices to find replaced edges. */ isAlive(asOf?: AsOf): Promise<boolean>; getEffective(asOf?: AsOf): Promise<Timestamp>; /** * If dest is not provided (or 0), the edge will be removed. This exact edge * with the same Muid will never exist again. The only way to "revive" it is to reset * the database or its edgeType. In that case, a new edge will be created with the same * source, target, value, and properties. * @param dest a timestamp to move the edge to. If 0 or not specified, the edge will be removed. * @param purge completely remove the edge's entry from the datastore? * @param bundlerOrComment a Bundler object or a string comment to add to the movement entry. */ remove(dest?: number, purge?: boolean, bundlerOrComment?: string | Bundler): Promise<void>; }