Search code examples
javascriptorientdb

Getting an rid after executing a command in OrientDB javascript function


I'd like to get a newly created record id after executing a command on a non-transactional graph database in OrientDB's function. For instance,

var gdb = orient.getGraphNoTx();

var v = gdb.command("sql", "create vertex TestV set time = ?, note = ?", [(new Date().getTime()), 'note']);

//how do i refer to v.rid after creation?

return true;

I tried all different options like, v.rid, v['@rid'], v.field('rid'), etc. I am not even sure what type of object is returned from the gdb.command().

What I know so far is that the type of returned value v is object. v.toString() does not provide any valuable insight on it though.

Any ideas?


Solution

  • var gdb = orient.getGraphNoTx();
    
    var v = gdb.command("sql", "create vertex TestV set time = ?, note = ?", [(new Date().getTime()), 'note']);
    
    print(v.getRecord().field('@rid'));
    
    return true;