時(shí)間:2024-02-28 13:28作者:下載吧人氣:21
本文介紹了mongodb如何對文檔內(nèi)數(shù)組進(jìn)行過濾的方法步驟,分享給大家,具體如下:
mongodb文檔內(nèi)包含數(shù)組,需要將數(shù)組中符合條件的數(shù)據(jù)過濾出來并返回結(jié)果集,可以用兩種方式來查詢group或filter。
數(shù)據(jù)源:
{ "_id" : ObjectId("5bbcc0c9a74db9804e78a157"), "uid" : "1000001", "name" : "zhangsan", "addrs" : [ { "is_query" : "1", "city" : "北京" }, { "is_query" : "0", "city" : "上海" }, { "is_query" : "1", "city" : "深圳" } ] } { "_id" : ObjectId("5bbcc167a74db9804e78a172"), "uid" : "1000002", "name" : "lisi", "addrs" : [ { "is_query" : "0", "city" : "北京" }, { "is_query" : "0", "city" : "上海" }, { "is_query" : "1", "city" : "深圳" } ] }
網(wǎng)友評論