Search code examples
javascriptorientdb

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.


Solution

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