Cloud Code 推送用户和查询
Cloud Code Push User and Queries
我正在尝试执行以下操作,查询明天处于“新建”状态的未决工单数量。查询 Employee(安装对象上的指针),然后获取我需要推送到的设备,最后发送推送。我对 JavaScript 不是很熟悉,所以我不确定我做错了什么。
我得到的错误是:main.js: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);
}
});
}
);
我在 Error3 上遇到错误:[object Object]
data :{
alert: (numberFound + " work orders promised for tomorrow with a status of New.");
}
在这里你定义了一个对象,所以你不应该有一个 ;
因为你现在有一个备用的 ;
,你可以把它放在那里:
var workOrderObjs = new [];
这不是强制性的,因为 JS 很古怪,但强烈建议不要依赖自动添加终止符。
我正在尝试执行以下操作,查询明天处于“新建”状态的未决工单数量。查询 Employee(安装对象上的指针),然后获取我需要推送到的设备,最后发送推送。我对 JavaScript 不是很熟悉,所以我不确定我做错了什么。
我得到的错误是:main.js: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);
}
});
}
);
我在 Error3 上遇到错误:[object Object]
data :{
alert: (numberFound + " work orders promised for tomorrow with a status of New.");
}
在这里你定义了一个对象,所以你不应该有一个 ;
因为你现在有一个备用的 ;
,你可以把它放在那里:
var workOrderObjs = new [];
这不是强制性的,因为 JS 很古怪,但强烈建议不要依赖自动添加终止符。