Caveat: I do not have a lot of experience with Orient.
However, it seems strange to me that you would store your email address
data as separate vertices joined by edges - unless a single email address
vertex could be owned by two or more user vertices.
Would it not make more sense for these addresses to be stored as embedded
lists? This should surely permit you to retrieve a JSON result of the type
you refer to (minus the rid, of course).
On Saturday, 15 August 2015 00:18:57 UTC+1, Charles Munat wrote:
>
> I have User vertices and EmailAddress vertices connected by Owns edges.
>
> I eventually want to return this information from a JSON API with the
> email addresses nested inside the user hashes, thus:
>
> {
> "users": [
> {
> "name": "Joe",
> "emails": [
> {
> "address": "[email protected] <javascript:>",
> "isSubscriber": true
> "@rid": "20:0"
> },
> {
>
> "address": "[email protected] <javascript:>",
> "isSubscriber": false
> "@rid": "20:1"
> }
> ]
> },
> ...
> ]
> }
>
> I have come up with a query that allows me to list the emails as an array
> of addresses, but I want the full objects. Is there a way to do this with a
> single query? Can I nest further by doing further traversals? Or does this
> require multiple queries and then some matching up in my code?
>
> Here's the best query I've come up with so far, but it falls short:
>
> select *, out('Owns').address as emails from User
>
> Thanks!
>
> Chas.
>
--
---
You received this message because you are subscribed to the Google Groups
"OrientDB" 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.