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

how to get the parse user from the afterSave function

如何在 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;
        }
    });

});

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

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