Hi Lucas,
You can use traversedVertex() function to get the root traversal node, eg.
select unionall(devices) as devices, root from (
select traversedVertex(0) as root, out('HasResource') as devices from (
traverse out('HasArea') from (
select from Area where <your criteria here>
)
)
) group by root
traversedVertex(0) means the root node of the traversal, traversedVertex(1)
means the first traversal step an so on.
You can also use it with negative values, eg. traversedVertex(-1) means
last traversed vertex
Luigi
2015-08-27 17:43 GMT+02:00 Lucas Lira Gomes <[email protected]>:
> Hi all,
>
> I have a class named Area and one named Device. One area could be part of
> another via the HasArea edge and a device could be part of an Area via a
> HasResource. The problem is that, when I query all areas, I would like to
> receive also the RIDs of all Devices that are part of it. And by being part
> I mean even if it is a Device of a sub-area. That is, if I have a House as
> the root area, a bathroom with Device1 and a Kitchen with Device 2, the
> House should also have both Device1 and Device2 in a column.
>
> I have managed to do that, but only if I query for every Area in separate.
> For instance, in the example bellow #21:0 is an Area.
>
> select unionall(devices) as devices from (select @rid, name,
> out('HasResource') as devices from (traverse out('HasArea') from #21:0))
>
> However, I would like to be able to do that in a single query, if
> possible. Anyone know how to accomplish that in a single OSQL query?
>
> Regards, Lucas Lira Gomes.
>
> --
>
> ---
> 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.
>
--
---
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.