Support for Conditional Updates

Is there a way currently through the REST API to perform a conditional update on a single item? I want to only update a relationship on an item if no relationship has been established on this said item already. I am hoping there is a way to do this, and if not, is there some other way I can support concurrency and provide some protection to the data?

Hi Donald,

There is no built-in way to do this, however, it might be possible to achieve what you want using Caching API and/or Atomic Counters. Could you please describe the use-case you have in mind in more specific terms so we can suggest a solution?


Thanks for getting back to me. The use case I am going for is one where I have a collection of “Items” in Backendless and I want user’s to be able to “claim” these items where adding that user as a one-to-one relationship with the item would effectively place that user as the owner of the item under the “claimedBy” column. I would use a conditional update, providing that the updates are atomic, to ensure that the relationship can only be established if the “claimedBy” field is null for that item. The concern now is that more than one request can successfully process the update to the relationship if the requests happened almost at the same time, thus leaving user’s with a potential false positive.

I will take a closer look at the Caching API to see what that offers. I did look at the Atomic Counters API as well as attempted to see if I could use the “bulk” update operation which allows for a “where” clause but that seemed to not like having the “objectId” field in the where clause as a condition.