测试积点老人 发表于 2020-2-10 13:18:53

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 要怎么写查询语句?

jingzizx 发表于 2020-2-11 10:49:09

按照语法测试编写
页: [1]
查看完整版本: mongdb怎么实现同时find和count