edges
An edge represents a directed relationship between two nodes. Every edge carries four required fields: a unique string id, a source node id, a target node id, and a relationship string that names the type of connection (for example "KNOWS", "WORKS_AT", or "ATTENDED"). An optional properties map lets you attach arbitrary key-value metadata — numbers, strings, or booleans — to each edge.
Both source and target must reference node ids that already exist in the graph. Passing an unknown node id to edges.add will fail. Note that removing a node does not automatically remove its incident edges; call api.edges.remove() or use api.edges.where() to clean up connections before or after removing a node.
The CRUD lifecycle mirrors the nodes namespace: use edges.add to insert one or more edges, edges.update or edges.updateBatch to merge new property values onto existing edges without touching other fields, and edges.remove to delete by id or any EdgeSelector. edges.clear removes every edge at once. All write operations are routed through the command executor, so they are recorded in the undo/redo history and emit events on the shared event bus ("edges:added", "edges:removed", "edges:updated").
Read operations are synchronous and do not touch history: edges.get retrieves a single edge by id (returns null if absent), edges.getAll returns a shallow copy of all edges, edges.count returns the current total, and edges.has checks existence without fetching the full object.
Two convenience methods support graph traversal without a full scan: edges.between returns all directed edges from a specific source to a specific target, and edges.connectedTo returns every edge incident to a given node — useful for computing degree or finding immediate neighbors.
For richer filtering — by relationship type, source, target, or a custom predicate — edges.where returns a chainable EdgeQuery builder. Call .data() to materialise the matching EdgeData[], .ids() for just the id strings, .count() for the count, or chain .remove() to delete matches in one step.