Skip to content

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) -> bool
  • source, target : str Ids of existing records; they must differ.

  • link_type : str A lowercase letter, then up to 63 lowercase letters, digits or _.

True if the link is new, False if it already existed.

  • ValueError An id is unknown, source equals target, link_type is not a valid name, or a limit would be exceeded: 1,024 outgoing links for source, 100,000 incoming links for target, 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; upsert keeps it on the new version.
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"))
# True
print(db.link("a", "cites", "b"))
# False