I have simple function (javascript language)like this.
var db = orient.getDatabase();
var result = db.command("Insert into Counter (Name, Value) values('Test1',0)");
How can I get New @rid from result
variable?
I have tried like this
return result[0].field('@rid');
But it wont worked.
I tried you case by following these steps:
Structure:
CREATE CLASS Counter
CREATE PROPERTY Counter.Name STRING
CREATE PROPERTY Counter.Value INTEGER
To retrieve the just inserted record @rid
by using a Javascript function you can change your function in this way:
JS function:
var db = orient.getDatabase();
var result = db.command("Insert into Counter (Name, Value) values('Test1',0)");
return result.getRecord().field('@rid').toString();
Output:
[
{
"@type": "d",
"@version": 0,
"value": "#12:0"
}
]
Studio:
Hope it helps