Skip to main content

Add Edges to Collection

This page explains how to add edges to a Graph Edge collection.

Add an Edge with the Console

To add edge documents to a collection:

  1. Log in to your Macrometa account.
  2. Click Data > Collections.
  3. 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.
  4. Click New Document.
  5. Enter information in the fields.
    • _from - Document _id from which the relationship originates.
    • _to - Document _id to which the relationship is defined.
    • _key - Optional. If left blank, then Macrometa automatically generates a key.
  6. Click Create.

Add Edges from a File

To add edge documents to a collection from a JSON or CSV file:

Import a Document

  1. Log in to your Macrometa account.

  2. Click Data > Collections.

  3. 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.

  4. Click the import icon, which is a down arrow pointing to a file box.

  5. Click Choose File, then browse to the file containing the documents you want to import.

  6. 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.

Add Documents with Code

The example below shows how to use Python or JavaScript to insert documents into an employees collection.

    client = C8Client(protocol='https', host='play.paas.macrometa.io', port=443,
email='nemo@nautilus.com', password="xxxxxx",
geofabric='_system')
client.insert_document(collection_name='employees', document={'_key':'Jean', 'firstname': 'Jean', 'lastname':'Picard', 'email':'jean.picard@macrometa.io'})

docs = [
{'_kefabricy':'James', 'firstname': 'James', 'lastname':'Kirk', 'email':'james.kirk@mafabriccrometa.io'},
{'_kefabricy': 'Han', 'firstname': 'Han', 'lastname':'Solo', 'email':'han.solo@macrfabricometa.io'},
{'_kefabricy': 'Bruce', 'firstname': 'Bruce', 'lastname':'Wayne', 'email':'bruce.wayne@mfabricacrometa.io'}
]

client.insert_document(collection_name='employees', document=docs)