0
votes

I am trying to run a batch command in orientdb where I am updating records (which can be either edges or vertices). I am trying to run this in a batch command such that I get back the property "name" and the rid from the database (assume that "name is guaranteed to exist).

So, I have the following batch command:

begin;
let a0 = update #44:845 merge {"name": "B4"} return after ;
let a1 = update #44:849 merge {"name": "Name4"} return after ;
let a2 = update #42:297 merge {"name": "Name2"} return after ;
let a3 = update #43:278 merge {"name": "B1"} return after ;
let a4 = update #42:298 merge {"name": "B2"} return after ;
let a5 = update #29:15698 merge { "name": "Name1""} return after ;
commit retry 100;
return [$a0,$a1,$a2,$a3,$a4,$a5]

But instead of returning objects, this is returning orientdbLinks, which doesn't allow me to get the names of the objects.

At the end of my batch function, I want to return a dictionary like this: {"B4", "44:845", "Name3": "44:849", . . .}

Is this possible? I have tried a bunch of different commands

let a0 = update #44:845 merge {"name": "B4"} return after ;
let a0 = update #44:845 merge {"name": "B4"} return after [$current@rid, $current.name]; #This fails entirely
let a0 = update #44:845 merge {"name": "B4"} return after $current;

but no matter what I try, it is just returning a OrientDBRecordLink instead of a proper OrientDBStorageObject. As far as I can tell, there is no way to get properties from an OrientDBRecordLink, is there?

Does anyone know how I can do this?

1
What is it exactly that is being returned now? just the references to the objects? - mitchken
At the moment what is being returned is an pyorient.otypes.OrientRecordLink object - Diemo

1 Answers

0
votes

To return a property of an object you just need to append the .field on your variable, as for the dictionary you should look into returning a map:

return { "$a0.name" : $a0.@rid, "$a1.name" : $a1.@rid, "$a2.name" : $a2.@rid, "$a3.name" : $a3.@rid, "$a4.name" : $a4.@rid, "$a5.name" : $a5.@rid }

OrientDB Docs | SQL-Batch