大阿夏
大阿夏
  • 发布:2023-02-10 17:55
  • 更新:2023-02-10 18:18
  • 阅读:238

多表联查如何根据条件

分类:uniCloud

如题我如果需要连表查询tools表,只想返回tools表字段is_state=0的数据,而不是返回所有,请问怎么写。

const collection = await db.collection('tool-classify').aggregate().lookup({  
                                                                    from:'tools',   //关联表  
                                                                    localField:'_id',   //主表字段  
                                                                    foreignField:'classify_id', //关联表字段  
                                                                    as:'toolList'   ,//别名  
                                                                }).match({  
                                                                    toolList: {  
                                                                        is_state: 0  
                                                                    }  
                                                                }).end()
2023-02-10 17:55 负责人:无 分享
已邀请:
DCloud_uniCloud_WYQ
  • 大阿夏 (作者)

    能不能帮我把这个问题的答案写出来,感谢。

    2023-02-10 18:26

该问题目前已经被锁定, 无法添加新回复