parse-platformparse-cloud-codeafter-save

Parse.com afterSave trigger for object with array of other objects


I need to analyse some data after it has been uploaded to Parse and saved but the data is an object that contains an array of other objects...

Parent
-------
children : [Child]

I'm just not certain if the afterSave will trigger before all the children objects are uploaded and saved? Is it guaranteed that they will be there on the afterSave of the Parent object?

Thanks


Solution

  • In general the answer should be yes, they must always exist.

    If it's an array of plain (not parse) objects then the data is directly there. If it's an array of parse objects (so an array of pointers) then the objects have to exist before they have ids and pointers can be generated for them. Same goes for a relationship to other parse objects.

    Now, once the relationship to a parse object has been created it is not required that the parent is saved after the child - that is up to your code to guarantee if you need to. Indeed, it could just be that the child is saved and the parent isn't dirty so doesn't need to be saved...