Type to use for document data. Defaults to any
.
A EdgeCollection instance for this edge collection.
Name of the collection.
Retrieves the edge matching the given key or id.
Throws an exception when passed a edge or _id
from a different
collection, or if the edge does not exist.
const graph = db.graph("some-graph");
const collection = graph.edgeCollection("friends")
try {
const edge = await collection.edge("abc123");
console.log(edge);
} catch (e: any) {
console.error("Could not find edge");
}
const graph = db.graph("some-graph");
const collection = graph.edgeCollection("friends")
const edge = await collection.edge("abc123", { graceful: true });
if (edge) {
console.log(edge);
} else {
console.error("Edge does not exist");
}
Document _key
, _id
or object with either of those
properties (e.g. a edge from this collection).
Optional
options: GraphCollectionReadOptionsOptions for retrieving the edge.
Retrieves the edge matching the given key or id.
Throws an exception when passed a edge or _id
from a different
collection, or if the edge does not exist.
const graph = db.graph("some-graph");
const collection = graph.edgeCollection("friends")
try {
const edge = await collection.edge("abc123", false);
console.log(edge);
} catch (e: any) {
console.error("Could not find edge");
}
const graph = db.graph("some-graph");
const collection = graph.edgeCollection("friends")
const edge = await collection.edge("abc123", true);
if (edge) {
console.log(edge);
} else {
console.error("Edge does not exist");
}
Document _key
, _id
or object with either of those
properties (e.g. a edge from this collection).
If set to true
, null
is returned instead of an
exception being thrown if the edge does not exist.
Checks whether a edge matching the given key or id exists in this collection.
Throws an exception when passed a edge or _id
from a different
collection.
const graph = db.graph("some-graph");
const collection = graph.edgeCollection("friends")
const exists = await collection.edgeExists("abc123");
if (!exists) {
console.log("Edge does not exist");
}
Document _key
, _id
or object with either of those
properties (e.g. a edge from this collection).
Removes an existing edge from the collection.
Throws an exception when passed a edge or _id
from a different
collection.
const db = new Database();
const collection = db.collection("friends");
const doc = await collection.edge("musadir");
await collection.remove(doc);
// edge with key "musadir" deleted
Document _key
, _id
or object with either of those
properties (e.g. a edge from this collection).
Optional
options: GraphCollectionRemoveOptionsOptions for removing the edge.
Replaces an existing edge in the collection.
Throws an exception when passed a edge or _id
from a different
collection.
const db = new Database();
const collection = db.collection("friends");
await collection.save(
{
_key: "musadir",
_from: "users/rana",
_to: "users/mudasir",
active: true,
best: true
}
);
const result = await collection.replace(
"musadir",
{ active: false },
{ returnNew: true }
);
console.log(result.new.active, result.new.best); // false undefined
Document _key
, _id
or object with either of those
properties (e.g. a edge from this collection).
Optional
options: GraphCollectionReplaceOptionsOptions for replacing the edge.
Inserts a new edge with the given data
into the collection.
const db = new Database();
const collection = db.collection("friends");
const result = await collection.save(
{ _from: "users/rana", _to: "users/mudasir", active: false },
{ returnNew: true }
);
The contents of the new edge.
Optional
options: GraphCollectionInsertOptionsOptions for inserting the edge.
Updates an existing edge in the collection.
Throws an exception when passed a edge or _id
from a different
collection.
const db = new Database();
const collection = db.collection("friends");
await collection.save(
{
_key: "musadir",
_from: "users/rana",
_to: "users/mudasir",
active: true,
best: true
}
);
const result = await collection.update(
"musadir",
{ active: false },
{ returnNew: true }
);
console.log(result.new.active, result.new.best); // false true
Document _key
, _id
or object with either of those
properties (e.g. a edge from this collection).
Optional
options: GraphCollectionReplaceOptionsOptions for updating the edge.
Generated using TypeDoc
Represents a EdgeCollection of edges in a Graph.