Hi everyone,
I'm trying to build an AQL query that iterates over edges that point to
objects from 2 different collections (say, A and B). The goal is to return
a list of those heterogenous objects and within the query, I have to
perform some specific projections (depending whether they are A or B).
Let's imagine that my A objects are like:
{
"field": "value"
}
and B are like:
{
"ids": ["id1", "id2"]
}
What I would like to achieve is:
FOR object in 1 OUTBOUND 'coll/start' edgeColl
LET type = PARSE_IDENTIFIER(object).collection
LET content = type == 'A' ? MERGE(object, { "some": "other field" }) : MERGE
(object, { profiles: (FOR id IN object.ids RETURN DOCUMENT('otherColl', id))
})
RETURN { type: type, content: content }
This fails because objects A don't have any *ids* field, so I got an error
saying that I can only iterate over an array. This shows that both options
of the ternary operator are somehow evaluated... This can be easily
demonstrated with:
LET arr = 'hello'
RETURN IS_ARRAY(arr) ? (FOR i IN arr RETURN i) : arr
This will fail in the same way.
So basically I'm looking for advises on how to perform that conditional
projection, any comment or hint will be very welcome!
Thanks,
Thomas
--
You received this message because you are subscribed to the Google Groups
"ArangoDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.