0

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

我有另一个模型称为Profile哪个belongsToOne用户。

现在,我想populate通知相关user人员及其profile...

我努力了:

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

向我投掷Impossible to find the plugin where strapi.query has been called.

也试过:

notification.user.populate('profile')

也没有运气

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

4

3 回答 3

0

你不需要query

您将不得不使用插件User模型的猫鼬模型实例。Users & Permissions

return strapi.plugins['users-permissions'].models.user.
  .findOne(user_id)
  .populate('profile');
于 2018-10-18T08:50:11.257 回答
0

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

所有strapi对象都如屏幕截图所示。

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

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

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

于 2021-01-28T21:55:03.757 回答
0

我在这里遇到同样的问题。所有这些都是未定义的:

strapi.query
strapi.plugins

全局strapi对象存在,只是不提供上面列出的属性......我错过了什么吗?我已经阅读了文档至少三遍......没有运气。

于 2020-02-14T17:50:55.427 回答