通过访问beforeSave值解析Javascript API云代码afterSave

通过访问beforeSave值解析Javascript API云代码afterSave,javascript,parse-platform,parse-cloud-code,Javascript,Parse Platform,Parse Cloud Code,我正在使用解析云代码进行保存前/后处理。我会在afterSave钩子中检查属性的beforeSave值——例如,在parseObj.get'status'从processing=>complete转换时执行一些操作。我可以访问beforeSave处理程序中更改的属性的oldVal/newVal,但是我找不到一种方法将oldVal传递给afterSave处理程序,而不保存为DB字段 我试图将这些值作为属性传递给response和response.object对象,但这两个对象都不能传递给after

我正在使用解析云代码进行保存前/后处理。我会在afterSave钩子中检查属性的beforeSave值——例如,在parseObj.get'status'从processing=>complete转换时执行一些操作。我可以访问beforeSave处理程序中更改的属性的oldVal/newVal,但是我找不到一种方法将oldVal传递给afterSave处理程序,而不保存为DB字段

我试图将这些值作为属性传递给response和response.object对象,但这两个对象都不能传递给afterSave


有什么想法吗?

我进一步研究了这个问题,最后我暂时保存到Parse对象,并像这样删除它:

//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()

我希望这有帮助。祝你好运

你有没有想过?我正在尝试做类似的事情。除了新值之外,我还需要知道afterSave期间记录上的旧值。不幸的是,不知道。除非保存到Parse.Object,否则我不知道如何在beforeSave和afterSave挂钩之间传递值-但这有点愚蠢。
//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()