我希望看到来自游戏类的数据,但用户字段是关系并给我 麻烦
游戏 对象ID | createdAt | updatedAt |用户(关系字段类型为用户类)
用户 对象ID | createdAt | updatedAt |名称
我想打印游戏数据:
<td>
的ObjectID </td>
<td>
小数字的名字,如John Smith,John Smith ...... </td>
这是我的代码
var game = Parse.Object.extend("Game");
var query = new Parse.Query(game);
query.include("users");
$("#content").append("<table id='results'></table>");
$("#results").text("");
query.find({
success: function(results) {
var html = "<tr><th>createdAt</th><th>users</th></tr>";
$("#results").append(html);
for (var i = 0; i < results.length; i++) {
var object = results[i];
var relation = object.relation('users');
relation.query().find({
success: function(toppings) {
// toppings is a list of toppings for this pizza
for(var j = 0; j < toppings.length; j++) {
alert(toppings[j].get("name"));
}
}
});
var html = "<tr><td>" + object.createdAt + "</td><td></td></tr>";
$("#results").append(html);
}
},
error: function(error) {
alert("Error: " + error.code + " " + error.message);
}
});
}
请帮助