0
votes

So I have an ArangoDB query here, but it throws an error while executed. It says syntax error and then says the error is somewhere around adminEdge._from but I can't find what the problem is :

let query = aql`
  FOR user IN ${users}
  FILTER user._key == ${body.userKey}
  FOR adminEdge IN ${administrates}
  FILTER adminEdge._from == user._id
  LIMIT 1
  RETURN { accountId: adminEdge._to, user }`;

users and administrates comes from db.collection that comes with ArangoDB. body is an object that is passed in as a parameter.

I'm pretty new to AQL so maybe I'm making some basic errors

2

2 Answers

0
votes

Since you are returning multiple columns, you cannot just return user, you have to list its columns just like you list adminEdge._to.

0
votes

Camba is right, your return value is not valid.

You could try something like

FOR user IN ${users}
  FILTER user._key == ${body.userKey}
  FOR adminEdge IN ${administrates}
      FILTER adminEdge._from == user._id
      LIMIT 1
      RETURN MERGE({accountId: adminEdge._to},user)