Skip to content Skip to sidebar Skip to footer

Parse Javascript API Cloud Code AfterSave With Access To BeforeSave Values

I'm using Parse Cloud Code to do before/afterSave processing. I'd check the beforeSave value of an attribute in the afterSave hook - for example, do something when parseObj.get('st

Solution 1:

I looked into this some more, and I ended up saving to the Parse object temporarily and removing it like this:

//Add the value you need to the object prior to saving using an "oldValue" key
yourPFObject["oldValue"] = value (this is in your SDK somewhere where the save happens)

//Get that value in afterSave in Cloud Code
var old = object.get("oldValue")

//Do whatever you need to do with "old"...

//Remove the temporary old value so it doesn't stay in the database
object.unset("oldValue") 
object.save()

I hope that helps. Good luck!


Post a Comment for "Parse Javascript API Cloud Code AfterSave With Access To BeforeSave Values"