解析后台作业不保存对象

时间:2014-12-31 04:58:00

标签: javascript parse-platform

好的,我试图在用户类中设置这些对象,但出于某种原因,它没有保存。它非常直接,或者看起来应该是:

这会让用户:

var actionCompleted = results[i].get("ActionComplete");
var user = results[i].get("User"); 

This Gets Objects:

 var moneyLost = user.get("MoneyLost");
 var daysRow = user.get("DaysInRow");
 var daysWoken = user.get("DaysWoken");
 var daysLate = user.get("DaysLate");

设置并保存对象:

 user.set = ("MoneyLost", moneyLost + bountyVal);
     user.set = ("DaysInRow", daysRow++);
     user.set = ("DaysWoken", daysWoken++);
     user.save(user, {
      success: function(gameScore) {
       // Execute any logic that should take place after the object is saved.
       alert('New object created with objectId: ' + gameScore.id);
      },
      error: function(gameScore, error) {
       // Execute any logic that should take place if the save fails.
       // error is a Parse.Error with an error code and message.
       alert('Failed to create new object, with error code: ' + error.message);
      }
     });

此设置并保存更多对象:

user.set = ("DaysInRow",0);
    user.set = ("DaysLate", daysLate++);
     user.save(user, {
      success: function(gameScore) {
       // Execute any logic that should take place after the object is saved.
       alert('New object created with objectId: ' + gameScore.id);
      },
      error: function(gameScore, error) {
       // Execute any logic that should take place if the save fails.
       // error is a Parse.Error with an error code and message.
       alert('Failed to create new object, with error code: ' + error.message);
      }
     });

1 个答案:

答案 0 :(得分:2)

您的语法已关闭,您需要预先增加而不是发布。

var actionCompleted = results[i].get("ActionComplete");
var user = results[i].get("User"); 

var moneyLost = user.get("MoneyLost");
var daysRow = user.get("DaysInRow");
var daysWoken = user.get("DaysWoken");
var daysLate = user.get("DaysLate");

user.set("MoneyLost", moneyLost + bountyVal);
user.set("DaysInRow", ++daysRow);
user.set("DaysWoken", ++daysWoken);
user.save(null, {
    success: function(gameScore) {
        // Execute any logic that should take place after the object is saved.
        alert('New object created with objectId: ' + gameScore.id);
    },
    error: function(gameScore, error) {
        // Execute any logic that should take place if the save fails.
        // error is a Parse.Error with an error code and message.
        alert('Failed to create new object, with error code: ' + error.message);
    }
});

user.set("DaysInRow", 0);
user.set("DaysLate", ++daysLate);
user.save(null, {
    success: function(gameScore) {
        // Execute any logic that should take place after the object is saved.
        alert('New object created with objectId: ' + gameScore.id);
    },
    error: function(gameScore, error) {
        // Execute any logic that should take place if the save fails.
        // error is a Parse.Error with an error code and message.
        alert('Failed to create new object, with error code: ' + error.message);
    }
});