在MongoDB中将WHERE与JOIN结合使用

时间:2019-03-05 14:59:06

标签: php mongodb

我有2个集合,我想根据另一个集合从一个集合中选择记录,

让我举例说明我的意思:

收藏1:

id, user_id, completed
1 , 1     , true
2 , 1     , false
3 , 2     , true
4 , 3     , true
5 , 4     , false

Collection2:

id, username
1 , test
2 , test 2
3 , test 3
4 , test 4

我要从collection2completed的{​​{1}}列为collection1的{​​{1}}中选择用户(结果应为(1,test),(2,test 4 )

因为我是MongoDB的新手,所以我不知道该怎么办,我可以使用false在MySQL和PostgreSQL中做到这一点,但是在这里我该怎么办?

我阅读了MongoDB文档中的aggregation-pipeline,但我不知道。

0 个答案:

没有答案