How to update only if newer data available

Hello,

Can you setup some server side code so you only update a row in a table if the updated value is newer than the one on file. Meaning that if the client has an older version than the server, it will just reject the save?

Thanks!

Yes, you can do that in a “beforeUpdate” event handler. In there you could fetch the latest copy of the same object and compare the “updated” field between what’s in the DB and the object which is about to be updated.

Regards,
Mark

So how do you do that?

com.backendless.servercode.extension.PersistenceExtender.Find() ?
I can’t really find any good example of actually pulling data from the backend.

Also, if I do notice that the server has newer code, how do I prevent the update?

You can use either REST API to load the object:

http://backendless.com/documentation/data/rest/data_basic_search.htm

or the one for Java:

http://backendless.com/documentation/data/android/data_basic_search.htm

To prevent an update you can throw an exception from the “before” handler.