How to create graph in ArangoDb using arangosh command line?

I am trying to execute the following JS file using arangosh to plot my graph. The file runs without errors, but when I go to the web interface, I see the graph, but not the vertices or edges on the graph.

 db._dropDatabase("database"); db. _createDatabase("database", [], [{username: "admin", passwd: "admin", active: true}]); db._useDatabase("database"); var graph_module = require("org/arangodb/general-graph"); var graph = graph_module._create("myGraph"); //Add top level documents graph._addVertexCollection("users"); graph._addVertexCollection("positions"); graph._extendEdgeDefinitions(graph_module._relation("has_worked_at", ["users"], ["positions"])); 

I save this file as database.js and then run the following command

 arangosh --javascript.execute database.js 
+5
source share
1 answer

A graph was created, two collections of vertices and a collection of edges, but they do not contain any documents (vertices and edges). If you add

 db.users.insert({_key:"Max"}); db.positions.insert({_key:"ArangoDB"}); db.has_worked_at.insert("users/Max", "positions/ArangoDB", {developer:true}); 

in your script, you will see two vertices and an edge in the chart viewer.

+3
source

Source: https://habr.com/ru/post/1236748/


All Articles