Skip to content

Instantly share code, notes, and snippets.

@spmallette
Created August 31, 2012 09:08
Show Gist options
  • Save spmallette/3550585 to your computer and use it in GitHub Desktop.
Save spmallette/3550585 to your computer and use it in GitHub Desktop.
OrientDB Classes
gremlin> graph = new OrientGraph("local:/tmp/orientgraph1")
==>orientgraph[local:/tmp/orientgraph1]
gremlin> graph.getRawGraph().setUseCustomTypes(true);
==>null
gremlin> graph.getRawGraph().createVertexType("Product");
==>Product
gremlin> graph.getRawGraph().createVertexType("Customer");
==>Customer
gremlin> graph.getRawGraph().createEdgeType("Sell");
==>Sell
gremlin> p = graph.addVertex("class:Product")
==>v[#6:-2]
gremlin> p.setProperty("brand", "Commodore")
==>null
gremlin> p.setProperty("model", "Amiga")
==>null
gremlin> c = graph.addVertex("class:Customer")
==>v[#6:-3]
gremlin> c.setProperty("name", "Luca")
==>null
gremlin> e = graph.addEdge("class:Sell", c, p, "sells")
==>e[#7:-4][#6:-3-sells->#6:-2]
gremlin> e.setProperty("price", 400)
==>null
gremlin> graph.stopTransaction(SUCCESS)
==>null
gremlin> graph.V
==>v[#6:0]
==>v[#6:1]
gremlin> graph.E
==>e[#7:0][#6:0-sells->#6:1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment