我使用Parse Server 3.0。我想从app.js或index.js调用Job(取决于Express JS应用的生成方式)。
在我的云代码main.js
中
// JOB
Parse.Cloud.job("myJob", async (request) => {
// params: passed in the job call
// headers: from the request that triggered the job
// log: the ParseServer logger passed in the request
// message: a function to update the status message of the job object
const { params, headers, log, message } = request;
message("I just started");
const query_log = new Parse.Query("Log");
const unique_aas_names = await query_log.distinct("aas_name");
// E.g.: {"result":["MHA-L29","MHA-L30"]}
message("I just finished");
console.log("unique_aas_names.length: " + unique_aas_names.length);
return unique_aas_names;
});
是否可以在Parse Server应用程序中从index.js调用Job?
您可以通过以下命令使用Parse JS SDK运行作业:
Parse.Cloud.startJob('myJob', myJobParams);