Add Graph Edge
This page explains how to add edges to a graph or Graph Edge collection.
You can add edges and edge definitions using either the graph commands or the collection commands. Best practice is to use the graph commands in most cases.
- Web Console - Graph
- Web Console - Collection
- REST API
- CLI
Follow these instructions to add a graph edge using the GDN console web UI.
- Log in to your Macrometa account.
- Click Data > Graphs.
- Click the graph to which you want to add edges.
- Click the vertex that is the beginning of the edge that you want to add, and then click the link icon (looks like a chain).
- Click the vertex that is the end of the edge that you want to add.
- (Optional) In the Create Edge screen, enter the _key if you want to assign a key.
- (Optional) In the Create Edge screen, select the Edge Collection that you want to add the edge to (if you have more than one edge collection in the graph).
- Click Create.
To add edge documents to a collection:
- Log in to your Macrometa account.
- Click Data > Collections.
- In the collection list, click the name of the edge collection to which you want to add an edge. If you aren't sure which collections are Graph Edge collections, then you can click Edge at the top of the page to see just Graph Edge collections.
- Click New Document.
- Enter the From Vertex information:
- From Collection - The name of the collection containing the origin document.
- Document key - Document
_id
from which the relationship originates.
- Enter the To Vertex information:
- From Collection -The name of the collection containing the destination document.
- Document key - Document
_id
to which the relationship is defined.
- (Optional) Enter a Document Key. If left blank, then Macrometa automatically generates a key.
- Click Create.
Add Edges from a File
To add edge documents to a collection from a JSON file:
Click Data > Collections.
In the collection list, click the name of the edge collection to which you want to add an edge. If you aren't sure which collections are Graph Edge collections, then you can click Edge at the top of the page to see just Graph Edge collections.
Click the import icon, which is a down arrow pointing to a file box.
Click Choose File, then browse to the file containing the documents you want to import.
Fill out any desired options and then click Import Documents.
- Select Primary Key - Macrometa can autogenerate your primary key, or you can select one from the file.
- Replace docs - Select this option to overwrite any existing documents with the same
_key
.
Use our interactive API Reference with code generation in 18 programming languages to Create a New Edge or Add a New Edge Definition between existing vertices.
Use the gdnsl graph edge create CLI command to create a new graph edge.