I am unable to update row by object id in parse. I am using parse javascript sdk. Below is the code that i tried, but unable to update the column "read" to true. So my code pass in a threadId and user object to get all the comments of the user under the thread. What i want to do is to mark all the comments as read = true. I am not sure why this code is not working? any idea how i can update my rows?
readAllById: function(threadId , user){
var ParseString = Parse.Object.extend("Comments");
var query = new Parse.Query(ParseString);
query.equalTo("threadId", threadId);
query.equalTo("user" , user);
query.ascending("createdAt");
query.include("user");
query.include("item");
return query.find().then(function(response){
for(var i = 0; i < response.length; i++ ) {
console.log(response[i]);
var object_id = response[i].id;
query.set("id", object_id);
query.set("read", true);
query.save();
}
}, function(error){
//something went wrong!
});
},