我有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
我要从collection2
中completed
的{{1}}列为collection1
的{{1}}中选择用户(结果应为(1,test),(2,test 4 )
因为我是MongoDB的新手,所以我不知道该怎么办,我可以使用false
在MySQL和PostgreSQL中做到这一点,但是在这里我该怎么办?
我阅读了MongoDB文档中的aggregation-pipeline,但我不知道。