Name of the graph.
Adds an edge definition to this graph.
Definition of a relation in this graph.
const db = new Database();
const graph = db.graph("some-graph");
await graph.addEdgeDefinition({
collection: "edges",
from: ["start-vertices"],
to: ["end-vertices"],
});
// The edge definition has been added to the graph
Adds the given collection to this graph as a vertex collection.
Collection to add to the graph.
const db = new Database();
const graph = db.graph("some-graph");
await graph.addVertexCollection("more-vertices");
// The collection "more-vertices" has been added to the graph
const extra = db.collection("extra-vertices");
await graph.addVertexCollection(extra);
// The collection "extra-vertices" has been added to the graph
Creates a graph with the given edgeDefinitions
and options
for this
graph's name.
Definitions for the relations of the graph.
Options for creating the graph.
const db = new Database();
const graph = db.graph("some-graph");
const info = await graph.create([
{
collection: "edges",
from: ["start-vertices"],
to: ["end-vertices"],
},
]);
// graph now exists
Deletes the graph from the database.
If set to true
, the collections associated with
the graph will also be deleted.
const db = new Database();
const graph = db.graph("some-graph");
await graph.drop();
// the graph "some-graph" no longer exists
Returns a graph.GraphEdgeCollection instance for the given collection name representing the collection in this graph.
Name of the edge collection.
const db = new Database();
const graph = db.graph("some-graph");
const info = await graph.create([
{
collection: "edges",
from: ["start-vertices"],
to: ["end-vertices"],
},
]);
const graphEdgeCollection = graph.edgeCollection("edges");
// Access the underlying EdgeCollection API:
const edgeCollection = graphEdgeCollection.collection;
Fetches all edge collections of this graph from the database and returns an array of graph.GraphEdgeCollection instances.
See also graph.Graph#listEdgeCollections.
const db = new Database();
const graph = db.graph("some-graph");
const info = await graph.create([
{
collection: "edges",
from: ["start-vertices"],
to: ["end-vertices"],
},
]);
const graphEdgeCollections = await graph.edgeCollections();
for (const collection of graphEdgeCollection) {
console.log(collection.name);
// "edges"
}
Fetches all edge collections of this graph from the database and returns an array of their names.
See also graph.Graph#edgeCollections.
const db = new Database();
const graph = db.graph("some-graph");
const info = await graph.create([
{
collection: "edges",
from: ["start-vertices"],
to: ["end-vertices"],
},
]);
const edgeCollectionNames = await graph.listEdgeCollections();
// ["edges"]
Fetches all vertex collections of this graph from the database and returns an array of their names.
See also graph.Graph#vertexCollections.
const db = new Database();
const graph = db.graph("some-graph");
const info = await graph.create([
{
collection: "edges",
from: ["start-vertices"],
to: ["end-vertices"],
},
]);
const vertexCollectionNames = await graph.listVertexCollections();
// ["start-vertices", "end-vertices"]
Removes the edge definition for the given edge collection from this graph.
Edge collection for which to remove the definition.
If set to true
, the collection will also be
deleted from the database.
const db = new Database();
const graph = db.graph("some-graph");
const info = await graph.create([
{
collection: "edges",
from: ["start-vertices"],
to: ["end-vertices"],
},
]);
await graph.removeEdgeDefinition("edges");
// The edge definition for "edges" has been replaced
Removes the given collection from this graph as a vertex collection.
Collection to remove from the graph.
If set to true
, the collection will also be
deleted from the database.
const db = new Database();
const graph = db.graph("some-graph");
const info = await graph.create([
{
collection: "edges",
from: ["start-vertices"],
to: ["end-vertices"],
},
]);
await graph.removeVertexCollection("start-vertices");
// The collection "start-vertices" is no longer part of the graph.
Replaces an edge definition in this graph. The existing edge definition for the given edge collection will be overwritten.
Definition of a relation in this graph.
Optional
options: ReplaceEdgeDefinitionOptionsconst db = new Database();
const graph = db.graph("some-graph");
const info = await graph.create([
{
collection: "edges",
from: ["start-vertices"],
to: ["end-vertices"],
},
]);
await graph.replaceEdgeDefinition({
collection: "edges",
from: ["start-vertices"],
to: ["other-vertices"],
});
// The edge definition for "edges" has been replaced
Replaces an edge definition in this graph. The existing edge definition for the given edge collection will be overwritten.
Edge collection for which to replace the definition.
Definition of a relation in this graph.
Optional
options: ReplaceEdgeDefinitionOptionsconst db = new Database();
const graph = db.graph("some-graph");
const info = await graph.create([
{
collection: "edges",
from: ["start-vertices"],
to: ["end-vertices"],
},
]);
await graph.replaceEdgeDefinition("edges", {
collection: "edges",
from: ["start-vertices"],
to: ["other-vertices"],
});
// The edge definition for "edges" has been replaced
Returns a graph.GraphVertexCollection instance for the given collection name representing the collection in this graph.
Name of the vertex collection.
Fetches all vertex collections of this graph from the database and returns an array of graph.GraphVertexCollection instances.
See also graph.Graph#listVertexCollections.
const db = new Database();
const graph = db.graph("some-graph");
const info = await graph.create([
{
collection: "edges",
from: ["start-vertices"],
to: ["end-vertices"],
},
]);
const vertexCollections = await graph.vertexCollections();
for (const vertexCollection of vertexCollections) {
console.log(vertexCollection.name);
// "start-vertices"
// "end-vertices"
}
Represents a graph in a database.Database.