1,799
社区成员




最近用了腾讯的数据库发现是MONGODB,然而以前一直用的是mysql
遇到的问题如下:
表A结构如下
{"_id":"0ab5303b6273dc20019c2cfb10d0c15e","student_name":"马里奥","class_id":"f6e08a646273dba2015f760c3f200cdf","together":[{"family_id":"8f75309d6273dd21017cfb1643f6d8e0"},{"family_id":"16db756f6273add90130f04846eeb77e"},{"family_id":"0a4ec1f9627be4f803436d455a383dfd"}],"updatedAt":1652286904184}
表B结构如下
{"_id":"6d85a2b9628113400450767c00d44c36","health_img":"https://xxx.com/61296620.jpg","picDate":1652544000000,"travel_img":"https://xx.com/61276686.jpg","person_id":"8f75309d6273dd21017cfb1643f6d8e0"}
表A中的together.family_id关联表B中的person_id
通过什么样的语句能把查询结果变成如下结构,对表B确定唯一性的字段是person_id和picDate,如果查出来多条取第一条即可,可以对表B通过picDate进行where过滤就更好了
{"_id":"0ab5303b6273dc20019c2cfb10d0c15e","student_name":"马里奥","class_id":"f6e08a646273dba2015f760c3f200cdf","together":[{"family_id":"8f75309d6273dd21017cfb1643f6d8e0","photoData":{"_id":"6d85a2b9628113400450767c00d44c36","health_img":"https://xxx.com/61296620.jpg","picDate":1652544000000,"travel_img":"https://xx.com/61276686.jpg","person_id":"8f75309d6273dd21017cfb1643f6d8e0"}},{"family_id":"16db756f6273add90130f04846eeb77e"},{"family_id":"0a4ec1f9627be4f803436d455a383dfd"}],"updatedAt":1652286904184}
有木有大佬救救我???