mongdb怎么实现同时find和count
mongdb怎么实现同时find和count假设有文档:
[
{ name: 'a', content: 'xxx', list: [ 'A', 'A', 'C' ] },
{ name: 'b', content: 'yyy' ,list: [ 'A', 'B' ] },
{ name: 'c', content: 'zzz', list: [ 'B' ] }
]
期望统计 list 中元素个数,并保持其他信息字段不变:
[
{ name: 'a', content: 'xxx', list: 3 },
{ name: 'b', content: 'yyy' ,list: 2 },
{ name: 'c', content: 'zzz', list: 1 }
]
请问在 mongodb 要怎么写查询语句?
按照语法测试编写
页:
[1]