[英]Cloud code - Parse.Object initializer isn't working
I'm probably missing something stupid, but my initializer function for a custom parse class isn't working in cloud code. 我可能缺少一些愚蠢的东西,但是自定义解析类的初始化函数在云代码中不起作用。 I have the following in my cloud code, and call the "createAStatisticTest" function from my client, which successfully creates and saves a new Statistics object, but doesn't update any of the data to 0. All of the data is (undefined). 我的云代码中包含以下内容,并从客户端调用“ createAStatisticTest”函数,该函数成功创建并保存了一个新的Statistics对象,但不会将任何数据更新为0。所有数据均为(未定义) 。 Can anyone point out what I'm doing wrong? 谁能指出我做错了什么?
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);
}
)
});
I based my implementation off of the js guide's Monster object example found here 我的实现基于js指南的Monster对象示例(在此处找到)
I had a similar problem a few weeks ago, where everything returned (undefined)
suddenly. 几周前,我遇到了类似的问题,所有内容突然返回(undefined)
。 I solved it by changing the JavaScript SDK version back to version 1.4.2 - so it seems Parse has a bug in their latest SDK version. 我通过将JavaScript SDK版本更改回1.4.2版来解决它-因此Parse似乎在其最新SDK版本中存在错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.