1

如何在 afterSave 函数中获取解析用户?

Parse.Cloud.afterSave(Parse.User, function(request) {
    Parse.Cloud.useMasterKey();


    console.log("username: "+request.user.username);


    query = new Parse.Query(Parse.User);
    query.equalTo("username", request.user.username);
    query.first ( {
        success: function(object) {

            //object.relation("users").add(request.user);
            //object.save();
            console.log("sucesss"+ object);

        },
        error: function(error) {
            throw "Got an error " + error.code + " : " + error.message;
        }
    });

});
4

1 回答 1

2

要获取保存的用户对象,请使用request.object. 要获取对类进行更改的用户对象User,请使用request.user. 在您的情况下,请使用第一个。

参考: http: //www.parse.com/docs/js/api/classes/Parse.Cloud.AfterSaveRequest.html

于 2015-12-01T06:22:27.790 回答