从 Strapi 中的另一个插件调用模型 [英] Call model from another plugin in Strapi

查看:46
本文介绍了从 Strapi 中的另一个插件调用模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Notification 模型,其中 belongsToMany 用户来自 users-permissions 插件.

I have a Notification model which belongsToMany users from users-permissions plugin.

我有另一个名为 Profile 的模型,它是 belongsToOne 用户.

I have another model called Profile which belongsToOne user.

现在,我想用相关的user 和他们的profile populate 通知...

Now, I want to populate the notification with related user and their profile ...

我试过了:

 await strapi.query("user", "users-permissions").find({_id: `model id`}).populate('profile')

向我抛出无法找到调用了 Strapi.query 的插件..

也试过了:

notification.user.populate('profile')

也没有运气

我也试过 strapi.plugins["users-permissions"].models.user 未定义!

推荐答案

全局 strapi 对象没有插件或查询属性.

Global strapi object do not have either plugins or query properties.

所有 strapi 对象都如截图所示.

All strapi object has is as shown in screenshot.

请注意,我正在尝试从以下位置查询插件模型:

Please note that I am trying to query plugin model from:

/admin/src/containers/HomePage/index.js

这篇关于从 Strapi 中的另一个插件调用模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆