Reference
db.link
Add a typed, directed link between two records.
Add the directed link source -link_type-> target.
db.link(source: str, link_type: str, target: str) -> boolParameters
Section titled “Parameters”-
source, target : str Ids of existing records; they must differ.
-
link_type : str A lowercase letter, then up to 63 lowercase letters, digits or
_.
Returns
Section titled “Returns”True if the link is new, False if it already existed.
Raises
Section titled “Raises”- ValueError
An id is unknown,
sourceequalstarget,link_typeis not a valid name, or a limit would be exceeded: 1,024 outgoing links forsource, 100,000 incoming links fortarget, 1,000,000 links or 1,024 link type names per database.
- Visible at once; durable after
db.save(), together with the records saved with it. - Deleting either record removes the link;
upsertkeeps it on the new version.
Examples
Section titled “Examples”import srvdb
db = srvdb.create("./vectors", dimension=128)db.add(["a", "b"], [[1.0] + [0.0] * 127, [0.0, 1.0] + [0.0] * 126], ["{}", "{}"])print(db.link("a", "cites", "b"))# Trueprint(db.link("a", "cites", "b"))# FalseSee also
Section titled “See also”- Links between records: Durability, delete and search expansion.
db.unlink: Remove a link.db.neighbors: List a record’s links.
Was this page helpful? Tell us in Discussions.