Parse Server-如何从app.js或index.js调用云代码中定义的作业

问题描述 投票:0回答:1

我使用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?

javascript parse-platform parse-server
1个回答
0
投票

您可以通过以下命令使用Parse JS SDK运行作业:

Parse.Cloud.startJob('myJob', myJobParams);
© www.soinside.com 2019 - 2024. All rights reserved.