mongodb自学习总结
1、mongodb中$elemMatch用法
功能:主要用户同级节点多属性过滤
a、以下这条语句会查出children.id="0730"的所有值db.getCollection('regioncodes').find({"children":{"$elemMatch":{"children.id":"0730","children.text":"长沙"}}})
b、用elemMatch多属性过滤后,只会找出满足id="0730"和text="岳阳"的值
db.getCollection('regioncodes').find({"children":{"$elemMatch":{"id":"0730","text":"岳阳"}}})
2、mongodb中怎么过滤不需要的字段或只展示需要的字段
说明:children.id=1表示展示,如果为0则隐藏不可见
db.getCollection('regioncodes').find({},{"children.id":1,"children.text":1})
相关推荐
lbyd0 2020-11-17
BigYellow 2020-11-16
sushuanglei 2020-11-12
我心似明月 2020-11-09
zhushenghan 2020-11-09
sunnnyduan 2020-10-16
不要皱眉 2020-10-14
xiaohai 2020-09-29
songxiugongwang 2020-09-22
萌亖 2020-09-17
LuckyLXG 2020-09-08
sdmzhu 2020-09-01
mkhhxxttxs 2020-09-16
xiaohai 2020-09-16
newcome 2020-09-09
jaylong 2020-08-19
大秦铁骑 2020-08-19
thatway 2020-08-19