【问题标题】:Strapi: What would be the best way to create import job?Strapi:创建导入工作的最佳方式是什么?
【发布时间】:2020-11-05 01:49:47
【问题描述】:

我对 Strapi 非常陌生,我正在寻找为其创建导入作业的最佳方法。

该作业应该作为 cron 运行并从临时数据库中获取其数据,这意味着没有上传文件等。

Strapi 作为 docker 容器部署到 kubernetes。

有一个导入器插件的例子,但它太大了,因为我在寻找更轻的东西时有不必要的前端。

【问题讨论】:

    标签: javascript import cron strapi


    【解决方案1】:

    你可以使用strapi控制器,例如餐厅是一个控制器

    在浏览器中调用它

    localhost/restaurant/import

    module.exports = {
      import: async (ctx) => {
    // getRecord(// code goes here)
    // strapi.services.restaurant.create(passData)
    }}
    

    1 - 获取数据,例如从 api https://www.example.com/wp-json/wp/v2/ 2 - 创建strapi记录strapi.services.restaurant.create()

    您可以使用 cron 调用 localhost/restaurant/import

    【讨论】:

      猜你喜欢
      • 2010-09-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-08-06
      • 1970-01-01
      • 2022-01-19
      • 2012-03-04
      相关资源
      最近更新 更多