0

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

Fogmeister
  • 76,236
  • 42
  • 207
  • 306

1 Answers1

1

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...

Wain
  • 118,658
  • 15
  • 128
  • 151
  • Thanks, the way we are uploading to Parse is to create the parent, create the children and add them to the parent and then "saveInBackground" on the parent object. This will save recursively. So it sounds like this will do what we want with your initial statement about the ids having to exist before the relationship can exist. – Fogmeister Jan 05 '16 at 17:28