Hi,
I have a model of Post and Comment relationship as following and want to
get a json tree from it. I am just wondering how this can be done from
console and Java API.
Thanks,
Steve
create database plocal:/home/steve/demodb
create class Post extends V;
create class Comment extends V;
create class Has extends E;
create vertex Post set id = '1', content = 'post1';
(#11:0)
create vertex Comment set id = '1', content = 'Comment1';
(#12:0)
create vertex Comment set id = '2', content = 'Comment2';
(#12:1)
create vertex Comment set id = '11', content = 'Comment11';
(#12:2)
create vertex Comment set id = '12', content = 'Comment12';
(#12:3)
create vertex Comment set id = '121', content = 'Comment121';
(#12:4)
create Edge Has from #11:0 to #12:0;
create Edge Has from #11:0 to #12:1;
create Edge Has from #12:0 to #12:2;
create Edge Has from #12:0 to #12:3;
create Edge Has from #12:3 to #12:4;
How can I do a query on #11:0 to get the following JSON tree?
[
{
"@RID": "#12:0",
"id": "1",
"content": "Comment1",
"Has": [
{
"@RID": "#12:2",
"id": "11",
"content": "Comment11"
},
{
"@RID": "#12:3",
"id": "12",
"content": "Comment12",
"Has": [
{
"@RID": "#12:4",
"id": "121",
"content": "Comment121"
}
]
}
]
},
{
"@RID": "#12:1",
"id": "2",
"content": "Comment2"
}
]
Here is what I can get
select from (traverse out('Has') from #11:0) where @CLASS = 'Comment';
----+-----+-------+----+----------+-------+--------------
# |@RID |@CLASS |id |content |in_Has |out_Has
----+-----+-------+----+----------+-------+--------------
0 |#12:0|Comment|1 |Comment1 |[#13:0]|[#13:1, #13:2]
1 |#12:2|Comment|11 |Comment11 |[#13:1]|null
2 |#12:3|Comment|12 |Comment12 |[#13:2]|[#13:3]
3 |#12:4|Comment|121 |Comment121|[#13:3]|null
----+-----+-------+----+----------+-------+--------------
--
---
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.