strapi - 内容管理器上的新帖子未触发 Strapi 服务“创建”
问题描述
我有“漫画”和“漫画章节”。两个模型之间的关系是漫画有很多漫画章节。
我想在每个新的漫画章节上更新漫画。
./api/comicchapter/services/Comicchapter.js
async create(data, { files } = {}) {
const entry = await strapi.query("comicchapter").create(data);
if (files) {
// automatically uploads the files based on the entry and the model
await this.uploadFiles(entry, files, { model: strapi.models.comicchapter });
return this.findOne({ id: entry.id });
}
// Updating comic field
await strapi.query("comic").update({ id: entry.comic.id }, { updated: new Date().toISOString() })
return entry;
},
如果我使用 http post 创建一个新的漫画章节,上面的代码可以工作,但是当我使用 contentmanager 创建一个新的漫画章节时它不起作用。使用生命周期 beforeSave afterSave 没有返回/填充 Comichapter 中的漫画。所以我不能更新漫画。有什么解决方案可以让它在内容管理器上运行吗?
解决方案
根据我对您正在尝试做的事情的陈述的评论,您可以尝试自定义 Content Manager 后端以满足您的需求。
您将不得不使用自定义概念https://strapi.io/documentation/3.0.0-beta.x/concepts/customization.html#plugin-extensions来自定义 Content Manager 插件。
推荐阅读
- flutter - 在 Flutter 中显示图像表单库或来自网络的同一视图
- qt - Qt Qml 源代码格式化不需要的行为
- android - 如何避免使用 zip4j lib 多次提取相同的文件?
- reactjs - 无法使用 useState 和 axios 响应与数组更新状态
- excel-formula - 如何在excel单元格中获取评估值?
- python - 如何将 pandas DataFrame 转换为只有值且没有列的 Python 字典?
- flutter-web - 添加新的小部件和可拖动的小部件
- php - 如何安全地处理末尾没有文件扩展名的图像 url 提交?
- dataframe - 如何复制一个数据框的值为空的字段的列名并创建另一个
- vbscript - 使用 vbscript 将 Base64 字符串转换为文件并在本地保存