我正在尝试执行以下操作,使用明天的新状态查询待处理的WorkOrders数。查询Employee(安装对象上的指针),然后获取我需要推送的设备,最后发送推送。我并不是那么熟悉JavaScript,所以我不确定我做错了什么。
我得到的错误是:main.js中的Uncaught SyntaxError:Unexpected token}:134
这将是发送部分,成功和错误函数在警报之后立即进入(即},{是它所说的行是错误)
任何想法或我如何做到这一点?我的经验很少,所以这是一个学习,因为我去打字。
Parse.Cloud.job("NotifyTomNextDaySO", function(request, response) {
var query = new Parse.query("WorkOrders");
var workOrderObjs = new []
var tomorrow = new Date();
tomorrow.setDate(tomorrow.getDate() + 1);
var startTomorrow = tomorrow.setHours(0,0,0,0);
var endTomorrow = tomorrow.setHours(23,59,59,59);
var numberFound = 0;
query.greaterThan("date", startTomorrow);
query.lessThan("date", endTomorrow);
query.equalTo("status", "New");
query.count({
success : function(count) {
numberFound = count;
var userQuery = new Parse.query("Employees");
userQuery.equalTo("firstName", "Tom");
userQuery.equalTo("lastName", "Sedletzeck");
userQuery.find({
success : function(employeeFound) {
var installQuery = Parse.Query(Parse.Installation);
query.equalTo("employee", employeeFound);
Parse.Push.send({
where: installQuery,
data :{
alert: (numberFound + " work orders promised for tomorrow with a status of New.");
}
}, {
success: function() {
},
error: function() {
}
});
}
});
}
});
}
);
编辑:
Parse.Cloud.job("NotifyTomNextDaySO", function(request, response) {
var query = new Parse.Query("WorkOrders");
var workOrderObjs = [];
var tomorrow = new Date();
tomorrow.setDate(tomorrow.getDate() + 1);
var startTomorrow = tomorrow.setHours(0,0,0,0);
var endTomorrow = tomorrow.setHours(23,59,59,59);
var numberFound = 0;
query.greaterThan("date", startTomorrow);
query.lessThan("date", endTomorrow);
query.equalTo("status", "New");
query.count({
success : function(count) {
numberFound = count;
var userQuery = new Parse.query("Employees");
userQuery.equalTo("firstName", "Trever");
userQuery.equalTo("lastName", "Ewing");
userQuery.find({
success : function(employeeFound) {
var installQuery = Parse.Query(Parse.Installation);
query.equalTo("employee", employeeFound);
Parse.Push.send({
where: installQuery,
data :{
alert: (numberFound + " work orders promised for tomorrow with a status of New.")
}
}, {
success: function(error) {
response.success("Done");
},
error: function(error) {
response.error("Error1: " + error);
}
});
}, error : function(error) {
response.error("Error2: " + error);
}
});
}, error : function(error) {
response.error("Error3: " + error);
}
});
}
);
Imm在Error3上出错:[object Object]
答案 0 :(得分:0)
data :{
alert: (numberFound + " work orders promised for tomorrow with a status of New.");
}
这里你定义了一个对象,所以你不应该有;
由于你现在有一个备用;
,你可以把它放在那里:
var workOrderObjs = new [];
这不是强制性的,因为JS很古怪,但强烈建议不要依赖终结器的自动添加。