Adding data to a graph in DataStax Studio

Steps to add data to a graph by writing and executing Gremlin code in Gremlin cells in a notebook.


To add data to a graph from a cell in your notebook:


  1. Add four more vertices and two other edges:
    user = graph.addVertex(label, 'user', 'id', 2, 'name', 'Jay Quest', 'role', 'customer')
    product = graph.addVertex(label, 'product', 'id', 3, 'name', 'digital camera')
    user.addEdge('bought', product)
    user = graph.addVertex(label, 'user', 'id', 3, 'name', 'Bartholmew Hicks', 'role', 'employee')
    product = graph.addVertex(label, 'product', 'id', 4, 'name', 'eraser')
    user.addEdge('manufactured', product)

  2. Create an edge between two existing vertices:
    1. Add this code to a new Gremlin cell:
      user = g.V().has('user', 'name', 'Jo Dowe').next()
      product = g.V().has('product', 'name', 'eraser').next()
      user.addEdge('bought', product)
    2. Switch the cell to display a graph.
    3. Select the Jo Dowe user vertex.