此错误通常发生在使用ArangoDB创建图时,可能是由于尝试使用非法文档键来创建图导致的。以下是一个可能导致此错误的代码示例:
const graphName = 'myGraph';
const edgeCollectionName = 'myEdgeCollection';
const db = new arangojs.Database();
// Connect to the database and create a new graph
db
.useBasicAuth('yourArangoDBUserName', 'yourArangoDBPassword')
.useDatabase('yourArangoDBName')
.collection(edgeCollectionName)
.create()
.then(() => {
return db.graph(graphName).create({
edgeDefinitions: [{
collection: edgeCollectionName,
from: ['fromVertexCollection'],
to: ['toVertexCollection']
}]
});
})
.then(() => {
console.log('Graph has been created!');
})
.catch((err) => {
console.error(err);
});
要修复此错误,您可以通过确保文档键是有效的来解决问题。文档键必须是字符串或数字,并且不能以'_”开头。如果您的文档键不符合这些条件,则需要对其进行更改,然后重新运行代码。