How to get document values in javascript

39 views
Skip to first unread message

Noorul Farhan Ahmed

unread,
Aug 15, 2015, 12:45:15 PM8/15/15
to OrientDB
Hi,

I have a function in javascript as below:

var totsum = 0;
var doc;
var i;
doc = orient.getDatabase().query("select productID from inf_list_item where userID = " + userID);
for ( i = 0; i < doc.length; i++){
  var prodIDDoc = doc[i];
}
return prodID;

Here, I want to get productID value from each document in doc. Please let me know hot to get it.

Thanks,
Noorul

user.w...@gmail.com

unread,
Aug 17, 2015, 6:05:33 AM8/17/15
to OrientDB
Hi Noorul,

Try this:

var totsum = 0;
var doc;
var i;
doc = orient.getDatabase().query("select productID from inf_list_item where userId='"+ userID+"'");
var array=[];
for ( i = 0; i < doc.length; i++)
{
  array.push(doc[i].field("productID"));
}
return array;

Regards,
Michela

Noorul Farhan Ahmed

unread,
Aug 17, 2015, 8:34:39 AM8/17/15
to OrientDB
Thanks Michela, it works.

It would be nice if more such examples are posted in documentation for the functions using javascript and groovy languages.
Reply all
Reply to author
Forward
0 new messages