Discussion:
[arangodb-google] Trying to query for all _to and _from data in a single variable
Martijn Geers
2018-03-16 08:36:28 UTC
Permalink
Hi guys,

I'm trying to use the ArangoDB Web Interface to query my database. What I'd
like to do is create a variable using the LET functionality, which contains
a list of all _to and _from elements of an edge collection.
It seems impossible to get them in a single neat list, rather I either do
something along the lines of 'return {"_to": edge._to, "_from": edge._from}
in which case they're still separated entities.
Or I do return [edge._to, edge._from] in which case I just get a lot of 2
element vectors, rather than a single list of several 10s or 100s of
entries.
How do I create equivalency for these elements? Hope you guys can help me
out.

Kind regards,

Martijn
--
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 arangodb+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Jan
2018-03-16 08:45:48 UTC
Permalink
Hi Martijn,

it should be easily possible to query all _from and all _to values. I am
just unsure how exactly you want them returned.
One example would be:

LET ids = APPEND(
FOR doc IN e RETURN doc._from,
FOR doc IN e RETURN doc._to
)
RETURN ids

This will return all _from and all _to values in a single array, with
duplicates.

To make the result array unique, all that is required is to add a call to
the UNIQUE function:

LET ids = UNIQUE(APPEND(
FOR doc IN e RETURN doc._from,
FOR doc IN e RETURN doc._to
))
RETURN ids

Hope this helps.

Best regards
Jan
Post by Martijn Geers
Hi guys,
I'm trying to use the ArangoDB Web Interface to query my database. What
I'd like to do is create a variable using the LET functionality, which
contains a list of all _to and _from elements of an edge collection.
It seems impossible to get them in a single neat list, rather I either do
something along the lines of 'return {"_to": edge._to, "_from": edge._from}
in which case they're still separated entities.
Or I do return [edge._to, edge._from] in which case I just get a lot of 2
element vectors, rather than a single list of several 10s or 100s of
entries.
How do I create equivalency for these elements? Hope you guys can help me
out.
Kind regards,
Martijn
--
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 arangodb+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Martijn Geers
2018-03-16 08:52:25 UTC
Permalink
Yeah that's exactly what I meant, thank you
Post by Jan
Hi Martijn,
it should be easily possible to query all _from and all _to values. I am
just unsure how exactly you want them returned.
LET ids = APPEND(
FOR doc IN e RETURN doc._from,
FOR doc IN e RETURN doc._to
)
RETURN ids
This will return all _from and all _to values in a single array, with
duplicates.
To make the result array unique, all that is required is to add a call to
LET ids = UNIQUE(APPEND(
FOR doc IN e RETURN doc._from,
FOR doc IN e RETURN doc._to
))
RETURN ids
Hope this helps.
Best regards
Jan
Post by Martijn Geers
Hi guys,
I'm trying to use the ArangoDB Web Interface to query my database. What
I'd like to do is create a variable using the LET functionality, which
contains a list of all _to and _from elements of an edge collection.
It seems impossible to get them in a single neat list, rather I either do
something along the lines of 'return {"_to": edge._to, "_from": edge._from}
in which case they're still separated entities.
Or I do return [edge._to, edge._from] in which case I just get a lot of 2
element vectors, rather than a single list of several 10s or 100s of
entries.
How do I create equivalency for these elements? Hope you guys can help me
out.
Kind regards,
Martijn
--
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 arangodb+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...