Hi,

don't know which language you use.

Did some development with the REST-HTTP-Api using ruby recently ( 
 https://github.com/topofocus/orientdb-rest )

Update...upsert did not work  and due to the lack of documentation, I 
realized a much more comfortable solution.
Instead of responding to an DB-Error,  I always query for a document first.
If this exists, I use the quick  document_uri."patch" api-call for an 
update.
Otherwise a document has to be inserted, which is time-consuming AND often 
requires more actions.

In ruby, you can provide a Block, which is executed only if an insert takes 
place.

I would write your term  as

 ror =  RestORiendb-Database
 ror.create_or_update_document o_class: 'IP' , where: { address: 
'10.10.1.1' }, set: { test: "test2"} 
 
 First a simple query containing  the where part only  is fired, 
 /query/{database}/sql/select from IP where address='10.10.1.1'/-1 (get)
 if a document is returned, its updated via document.patch, 
 /document/{database}/{rid} (patch) " attributes_to_json'
otherwise the complete dataset is inserted.
 
My solution provides three arguments: one for the determination if a 
document is present, then one for a quick-update and at last an optional 
block for a complete insert.
In ruby one can write:
 ror.create_or_update_document( 
               o_class: 'IP' , 
               where: { address: '10.10.1.1' }, 
               set: { test: "test2"}                    ) do  
    { :used_for => "Secret project", assigned_to: "Mr. Fu"}  # block 
provides a simple hash
 end


perhaps this helps you to clear your mind.

hartmut
  

 
 
 

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to