I want to update object i already have in parse.com with javascript; what i did is i retirevied the object first with query but i dont know how to update it.
我想用javascript更新我在parse.com中已有的对象;我做的是我首先用查询退回对象,但我不知道如何更新它。
here is the code i use, whats wrong on it?
这是我使用的代码,它有什么不对吗?
var GameScore = Parse.Object.extend("Driver");
var query = new Parse.Query(GameScore);
query.equalTo("DriverID", "9");
query.find({
success: function(results) {
alert("Successfully retrieved " + results.length + "DName");
results.set("DName", "aaaa");
results.save();
},
error: function(error) {
alert("Error: " + error.code + " " + error.message);
}
});
3 个解决方案
#1
19
The difference between the question and your answer may not be obvious at first- So for everyone who has happened here- Use query.first instead of query.find.
问题和你的答案之间的区别可能一开始并不明显 - 所以对于发生在这里的每个人 - 使用query.first而不是query.find。
query.find() //don't use this if you are going to try and update an object
returns an array of objects, an array which has no method "set" or "save".
返回一个对象数组,一个没有方法“set”或“save”的数组。
query.first() //use this instead
returns a single backbone style object which has those methods available.
返回一个具有这些方法的骨干样式对象。
#2
15
I found the solution, incase someone needs it later
我找到了解决方案,以后有人需要它
here it is:
这里是:
var GameScore = Parse.Object.extend("Driver");
var query = new Parse.Query(GameScore);
query.equalTo("DriverID", "9");
query.first({
success: function(object) {
object.set("DName", "aaaa");
object.save();
},
error: function(error) {
alert("Error: " + error.code + " " + error.message);
}
});
#3
3
If someone got msg "{"code":101,"error":"object not found for update"}", check the class permission and ACL of Object to enrure it's allowed to read and write
如果有人得到msg“{”代码“:101,”错误“:”找不到更新的对象“}”,请检查对象的类权限和ACL,以确保允许读取和写入
#1
19
The difference between the question and your answer may not be obvious at first- So for everyone who has happened here- Use query.first instead of query.find.
问题和你的答案之间的区别可能一开始并不明显 - 所以对于发生在这里的每个人 - 使用query.first而不是query.find。
query.find() //don't use this if you are going to try and update an object
returns an array of objects, an array which has no method "set" or "save".
返回一个对象数组,一个没有方法“set”或“save”的数组。
query.first() //use this instead
returns a single backbone style object which has those methods available.
返回一个具有这些方法的骨干样式对象。
#2
15
I found the solution, incase someone needs it later
我找到了解决方案,以后有人需要它
here it is:
这里是:
var GameScore = Parse.Object.extend("Driver");
var query = new Parse.Query(GameScore);
query.equalTo("DriverID", "9");
query.first({
success: function(object) {
object.set("DName", "aaaa");
object.save();
},
error: function(error) {
alert("Error: " + error.code + " " + error.message);
}
});
#3
3
If someone got msg "{"code":101,"error":"object not found for update"}", check the class permission and ACL of Object to enrure it's allowed to read and write
如果有人得到msg“{”代码“:101,”错误“:”找不到更新的对象“}”,请检查对象的类权限和ACL,以确保允许读取和写入