I am brand new to parse and have a very basic problem.
How can I update data in the DB using a function? It seems I am to stupid to get this to work :-) I tried many different scenarios but it will always create a new row in the DB.
My plan is to create the parse object and use it inside of various functions and save it back to the cloud at a later stage – or in this update function.
Thanks for your help.
My Code:
I embedded jquery and the parse-1.2.13.min.js inside the head tag and used a simple
a href link to call the updateData function.
Parse.initialize("xxx", "xxx");
var GameScore = Parse.Object.extend("GameScore");
var gameScore = new GameScore();
var query = new Parse.Query(GameScore);
query.equalTo("username", "Carlo");
query.first({
success: function(gameScore) {
console.log("ID: "+gameScore.id);
console.log("score: "+gameScore.get("score"));
},
error: function(object, error) {
console.log("The object was not retrieved successfully: "+error);
}
});
function updateData(newScore){
console.log("updateData called");
gameScore.set("score",newScore);
gameScore.save();
}
var newScore = "999";
gameScore
to anything other thannew GameScore()
... – RobH Dec 12 '13 at 10:26