require("@arangodb/aql/functions").register(
"MYFUNCTIONS::VERTEX::INDEGREE",
function(vertex,edge, node) {
"use strict";
AQL_Query(
(return( "for t in Transaction collect vertex_count=t._from with into n return x"))
)
}
);
throws the following exception
JavaScript exception: SyntaxError: Unexpected token 'return'
!require("@arangodb/aql/functions").register("MYFUNCTIONS::VERTEX::INDEGREE", function(vertex,edge, node) {"use strict"; AQL_Query((return( "for t in Transaction collect vertex_count=t._from with into n return x")))});
! ^^^^^^
stacktrace: SyntaxError: Unexpected token 'return'
Use the aql
template string handler to assamble the query, something like this should get you started:
require("@arangodb/aql/functions").register(
"MYFUNCTIONS::VERTEX::INDEGREE",
function(vertex,edge, node) {
"use strict";
let db = require('@arangodb').db;
let aql = require('@arangodb').aql;
let query = aql`
for t in Transaction
collect vertex_count=t._from with into n
return n
`;
return db._query(query).toArray();
}
);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.