super-newbie question about orientDB js

28 views
Skip to first unread message

3du...@gmail.com

unread,
Apr 21, 2015, 6:39:18 PM4/21/15
to orient-...@googlegroups.com

I want to create a custom json that is output by OrientDB. Rather than adapting my client application to consume the default JSON output, I want to conform the database output to what my client app needs to consume.

I'm trying to get the Name and percentage values from these results which the code underneath generates:

[
    {
        "@type": "d",
        "@rid": "#-2:0",
        "@version": 0,
        "percentage": "1"
    },
    {
        "@type": "d",
        "@rid": "#-2:1",
        "@version": 0,
        "Name": "Johnson Family Trust"
    }
]


var a = "select expand($c) let ";
var b = "$a = (select percentage from owns where in=#16:0), ";
var c = "$b = (select Name from (traverse in('owns').out('owns') from #16:0)), ";
var d = "$c = unionall($a, $b)";

v
ar x = g.command("sql", a+b+c+d, []);

return x;


My thought was to output an object in the following way, but the objects actually contain the @rid value, not the objects that are displayed, so the results are obviously null.


return {'percentage':x[0].percentage,'Name':x[1].Name};


Any ideas? If there are so many things wrong with the way I am going about this that you dont know where to start, please let me know.

Reply all
Reply to author
Forward
0 new messages