首页 > 解决方案 > Strapi 按多对多关系过滤

问题描述

我在strapi的postgresql中有两个表:商品和标签

Goods:
id | title
---------
1 | some name
2 | some name 2
3 | some name 4
…………………

Labels
id | title
------------
1 | some label 1
2 | some label 2
3 | some label n
………………………

它们通过一个附加表相互多对多连接

goods_labels__labels_goods
id | good_id      | label_id
----------------------------
1  |  1           | 1
2  |  1           | 2
2  |  2           | 1

我需要选择与 label.id = 1 和 label.id = 2 都有关系的商品,这只是第一个 id = 1 的产品。有什么方法可以使用带有 graphql 或书架的标准 Strapi 工具来实现它,还是作为最后的手段通过原始查询?我还需要对这个请求进行排序和限制

标签: node.jspostgresqlstrapibookshelf.js

解决方案


推荐阅读