将子查询转换为 JavaScript 以便在 Node 中使用

Converting the subquery into JavaScript to use in Node

我已尝试检索附加到顶点的文档。我分解了任务,在 Stack Overflow 的帮助下,我能够使用子查询找到解决方案。这工作得很好。

子查询:

LET startVertex = (
FOR doc IN spec
FILTER doc.serial_no == '"12345abc"'
LIMIT 1
RETURN doc._id
)[0]

FOR v IN 1 ANY startVertex belongs_to 
RETURN v

如何在 server.js 文件中使用它,以便在 运行 文件时与 ArangoDB 建立连接。

可以使用arangojs模块:

https://github.com/arangodb/arangojs

例如:

const arangojs = require('arangojs');

const db = new arangojs.Database({
  url: 'http://localhost:8529/or/whatever'
});
db.useDatabase('databaseName');
db.useBasicAuth('usename', 'password');

db.query(
  'insert query here', 
  {
    bindVar1: 'value',
    bindVar2: 'value',
  }
}).then(function(cursor) {
  cursor.all().then(function(result) {
    console.log(result);
  });
});