我可能缺少一些愚蠢的东西,但是自定义解析类的初始化函数在云代码中不起作用。我的云代码中包含以下内容,并从客户端调用“ createAStatisticTest”函数,该函数成功创建并保存了一个新的Statistics对象,但不会将任何数据更新为0。所有数据均为(未定义) 。谁能指出我做错了什么?
var Statistics = Parse.Object.extend("Statistics",
{ //instance methods
initialize: function(attrs, options)
{
this.newUsers = 0;
this.newBillableUsers = 0;
this.firstCut = 0;
this.additionalCuts = 0;
this.numCuts = 0;
this.totalBillableUsers = 0;
}
},
{} //class methods
);
//Create a single statistics object to show that the parameters inside of the intialize function aren't being set properlly
Parse.Cloud.define("createAStatisticTest", function(request, status)
{
var statistics = new Statistics();
statistics.save().then
(
function( statistics )
{
status.success("Saved the statistic object");
},
function( error )
{
status.error("There was an error saving the object: " + error.message);
}
)
});
我根据js指南的Monster对象示例here的实现
最佳答案
几周前,我遇到了类似的问题,所有内容突然返回(undefined)
。我通过将JavaScript SDK版本更改回1.4.2版来解决它-因此Parse似乎在其最新SDK版本中存在错误。
请查看this答案。