我有一个名为“Current1”的表,我将用户的对象保存为指针,如下所示:
当我点击这个指针时,我指向_User表。现在我正在尝试做非常简单的查询。我需要访问用户指针内的用户名,然后更新_User表中的内容。
我的问题现在使用指针访问'_User'表中的'username':
var aveGame2 = Parse.Object.extend("Current1");
var query2 = new Parse.Query(aveGame2);
query2.include("user");
query2.find({
success: function(results) {
for (var i = 0; i < results.length; i++)
{
var object = results[i];
//....
var user = object.get('user');
var username = user.get('username'); //<--Error is pointing to this line
//More operation
if(True)//Some conditions
{
Parse.Cloud.useMasterKey();
var query = new Parse.Query(Parse.User);
query.equalTo("username", username);
// Get the first user which matches the above constraints.
query.first({
success: function(anotherUser) {
anotherUser.set("prize", 10);
// Save the user.
anotherUser.save(null, {
success: function(anotherUser) {
// The user was saved successfully.
response.success("Successfully updated user.");
},
error: function(gameScore, error) {
// The save failed.
// error is a Parse.Error with an error code and description.
response.error("Could not save changes to user.");
}
});
},
error: function(error) {
response.error("Could not find user.");
}
});
错误:
[Error]: TypeError: Cannot call method 'get' of undefined
at e.query2.find.success
答案 0 :(得分:0)
经过几个小时检查每个字段后,我意识到我没有为_User表设置ACL作为公共读取。这可能对其他人有帮助。