0

Can someone explain me what happens in the following scenario:

We have 2 Cloud Code functions.

  • FunctionOne does a few async operations using promises, and modifies instances of class A.
  • FunctionTwo deletes instances of class A

What happens the call to FunctionTwo is made and an instance of type A is deleted, whilst that same instance is being modified and saved by a call to FunctionOne? (These calls could come from 2 different mobile devices for instance).

Joris Mans
  • 6,024
  • 6
  • 42
  • 69

1 Answers1

0

As far as i know, there is no transaction on parse model. For concurrency operations i've used a not safe workaround, putting a trivial random delay, for set a field like 'busy' at true, and finally restore it to false. This can reduce the problem, but of course it doesn't solve it.

In that case it will probably return an error like 'no object found for update' since you have an object with some dirty fields to save, but the object no longer exist on the db, since it has just been deleted by your FunctionTwo. Maybe, if that error occour while you're running the function FunctionOne, you could generate a new row instance for that class table, and save it again as new row ( this will generate a new row with your field BUT with a new different objectId of course )

Luca Iaco
  • 3,387
  • 1
  • 19
  • 20