Javascript Strapi查询数据只属于用户
斯特拉皮是个新手,我觉得这个问题很琐碎,但我想不出来 我正在尝试在公司控制器中创建一个查询,该查询只返回属于经过身份验证的用户的公司。(默认为返回数据库中的所有公司) 提前谢谢Javascript Strapi查询数据只属于用户,javascript,node.js,next.js,strapi,Javascript,Node.js,Next.js,Strapi,斯特拉皮是个新手,我觉得这个问题很琐碎,但我想不出来 我正在尝试在公司控制器中创建一个查询,该查询只返回属于经过身份验证的用户的公司。(默认为返回数据库中的所有公司) 提前谢谢 const entities = await strapi.query('companies').model.query(c => {c.where({users_permissions_users: { id: 1 }})}).fetch() 你们有关系表吗?是的,用户有很多公司。你们有关系表吗?是的,用户有很
const entities = await strapi.query('companies').model.query(c => {c.where({users_permissions_users: { id: 1 }})}).fetch()
你们有关系表吗?是的,用户有很多公司。你们有关系表吗?是的,用户有很多公司。
error: column "users_permissions_users" does not exist
Companies.js
{
"id": 2,
"company_name": "Tesla",
"description": null,
"url": null,
"email": null,
"location": null,
"employees": null,
"created_at": "2020-10-28T05:24:47.487Z",
"updated_at": "2020-10-28T05:24:47.528Z",
"job": null,
"logo": null,
"users_permissions_users": [
{
"id": 1,
"username": "spongebob",
"email": "spongebob@email.com",
"provider": "local",
"confirmed": true,
"blocked": false,
"role": 1,
"created_at": "2020-10-14T20:48:59.610Z",
"updated_at": "2020-10-28T05:24:47.521Z",
"company": 2,
"firstName": null,
"lastName": null,
"employer": null
}
]
}