Parse cloudcode beforeSave obtain pre-updated object

前端 未结 5 1966
独厮守ぢ
独厮守ぢ 2020-12-06 11:56

In a beforeSave hook I want to obtain the state of the object prior to the update. In this particular case it is to stop a user from changing their choice once

5条回答
  •  时光取名叫无心
    2020-12-06 12:51

    This Worked :

    var dirtyKeys = request.object.dirtyKeys();
    var query = new Parse.Query("Question");
    var clonedData = null;
            query.equalTo("objectId", request.object.id);
            query.find().then(function(data){
                var clonedPatch = request.object.toJSON();
                clonedData = data[0];
                clonedData = clonedData.toJSON();
                console.log("this is the data : ", clonedData, clonedPatch, dirtyKeys);
                response.success();
            }).then(null, function(err){
                console.log("the error is : ", err);
            });
    

提交回复
热议问题