Type to represent vertex document contents returned by the server (including computed properties).
Type to represent vertex document contents passed when inserting or replacing vertex documents (without computed properties).
A collections.DocumentCollection instance for this vertex collection.
Name of the collection.
Removes an existing vertex from the collection.
Throws an exception when passed a vertex or _id
from a different
collection.
Document _key
, _id
or object with either of those
properties (e.g. a vertex from this collection).
Optional
options: RemoveGraphDocumentOptionsOptions for removing the vertex.
const graph = db.graph("some-graph");
const collection = graph.vertexCollection("vertices");
await collection.remove("abc123");
// document with key "abc123" deleted
const graph = db.graph("some-graph");
const collection = graph.vertexCollection("vertices");
const doc = await collection.vertex("abc123");
await collection.remove(doc);
// document with key "abc123" deleted
Replaces an existing vertex in the collection.
Throws an exception when passed a vertex or _id
from a different
collection.
Document _key
, _id
or object with either of those
properties (e.g. a vertex from this collection).
The contents of the new vertex.
Optional
options: ReplaceGraphDocumentOptionsOptions for replacing the vertex.
const graph = db.graph("some-graph");
const collection = graph.collection("vertices");
await collection.save({ _key: "a", color: "blue", count: 1 });
const result = await collection.replace(
"a",
{ color: "red" },
{ returnNew: true }
);
console.log(result.new.color, result.new.count); // "red" undefined
Inserts a new vertex with the given data
into the collection.
The contents of the new vertex.
Optional
options: InsertGraphDocumentOptionsOptions for inserting the vertex.
const graph = db.graph("some-graph");
const collection = graph.vertexCollection("friends");
const result = await collection.save(
{ _key: "a", color: "blue", count: 1 },
{ returnNew: true }
);
console.log(result.new.color, result.new.count); // "blue" 1
Updates an existing vertex in the collection.
Throws an exception when passed a vertex or _id
from a different
collection.
Document _key
, _id
or object with either of those
properties (e.g. a vertex from this collection).
The data for updating the vertex.
Optional
options: ReplaceGraphDocumentOptionsOptions for updating the vertex.
const graph = db.graph("some-graph");
const collection = graph.collection("vertices");
await collection.save({ _key: "a", color: "blue", count: 1 });
const result = await collection.update(
"a",
{ count: 2 },
{ returnNew: true }
);
console.log(result.new.color, result.new.count); // "blue" 2
Retrieves the vertex matching the given key or id.
Throws an exception when passed a vertex or _id
from a different
collection.
Document _key
, _id
or object with either of those
properties (e.g. a vertex from this collection).
Optional
options: ReadGraphDocumentOptionsOptions for retrieving the vertex.
const graph = db.graph("some-graph");
const collection = graph.vertexCollection("vertices");
try {
const vertex = await collection.vertex("abc123");
console.log(vertex);
} catch (e: any) {
console.error("Could not find vertex");
}
const graph = db.graph("some-graph");
const collection = graph.vertexCollection("vertices");
const vertex = await collection.vertex("abc123", { graceful: true });
if (vertex) {
console.log(vertex);
} else {
console.error("Could not find vertex");
}
Retrieves the vertex matching the given key or id.
Throws an exception when passed a vertex or _id
from a different
collection.
Document _key
, _id
or object with either of those
properties (e.g. a vertex from this collection).
If set to true
, null
is returned instead of an
exception being thrown if the vertex does not exist.
const graph = db.graph("some-graph");
const collection = graph.vertexCollection("vertices");
try {
const vertex = await collection.vertex("abc123", false);
console.log(vertex);
} catch (e: any) {
console.error("Could not find vertex");
}
const graph = db.graph("some-graph");
const collection = graph.vertexCollection("vertices");
const vertex = await collection.vertex("abc123", true);
if (vertex) {
console.log(vertex);
} else {
console.error("Could not find vertex");
}
Checks whether a vertex matching the given key or id exists in this collection.
Throws an exception when passed a vertex or _id
from a different
collection.
Document _key
, _id
or object with either of those
properties (e.g. a vertex from this collection).
const graph = db.graph("some-graph");
const collection = graph.vertexCollection("vertices");
const exists = await collection.vertexExists("abc123");
if (!exists) {
console.log("Vertex does not exist");
}
Represents a collections.DocumentCollection of vertices in a Graph.