我正在尝试使用arangosh
执行以下JS文件来构建我的图形。该文件可以正常执行,但是当我进入Web界面时,我看到创建了一个图形,但是在图形中没有顶点或边。
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"]));
我把这个文件保存为
database.js
,然后运行以下命令。arangosh --javascript.execute database.js
var user1 = graph.users.insert({_key: "user1", name: "John Doe"}); var user2 = graph.users.insert({_key: "user2", name: "Jane Smith"}); var pos1 = graph.positions.insert({name: "junior manager"}); var pos2 = graph.positions.insert({name: "senior manager"}); var pos3 = graph.positions.insert({name: "developer"}); graph.has_worked_at.insert(user1._id, pos1._id, {company: "ACME corp."}); graph.has_worked_at.insert(user1._id, pos2._id, {company: "Sample inc."}); graph.has_worked_at.insert(user2._id, pos2._id, {company: "Foobar LLC"});
- stj