Ganapat
Ganapat

Reputation: 7488

OrientDB: Accessing query result data in Server side function

OrientDB allowes to create server side javascript functions. Is there any way to access intermediate query results inside server side javascript function. Eg. If I return query results, I get json response array as expected. But if I try to access query result inbetween function like:

var comps = db.query("SELECT code from Company");

db.begin();
for(var i=0; i<comps.length; i++){
  var c = comps[i];
  db.save({
    "@class":"Temp",
    col:  c.code
  });
}
db.commit();

return comps;

For above function I get blank values stored in column "col".

As per my observation, OrientDb returns context instead of actual results inside the function.

Thanks in advance.

Upvotes: 2

Views: 946

Answers (2)

Lvca
Lvca

Reputation: 9060

Replace c.code with c.field("code").

Upvotes: 1

rmuller
rmuller

Reputation: 12859

Based on your remark "OrientDb returns context instead of actual results inside the function" I assume you are working with Java 8. The point is, behavior of OrientDB differs between Java 8 and Java 7 in this respect (because of the different underlying Javascript engines: Nashorn vs Rhino). There are several known (related) issues, see this thread for example.

Upvotes: 1

Related Questions