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.
Prerequisites
- Create the schema.
To add data to a graph from a cell in your notebook:
Procedure
-
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') schema.edgeLabel('manufactured').create() user.addEdge('manufactured', product) g.V()
-
Create an edge between two existing vertices: