是否可以查询嵌入文档中特定键的值计数。
这是我的文件:
{ "_id" : 1, "drives" : [ {"fw": "A"}, {"fw": "B"} ] }
{ "_id" : 2, "drives" : [ {"fw": "B"}, {"fw": "C"} ] }
{ "_id" : 3, "drives" : [ {"fw": "A"}, {"fw": "C"} ] }
{ "_id" : 4, "drives" : [ {"fw": "A"}, {"fw": "D"} ] }
我想得到“fw”的计数:
输出:
计数:{“A”:3,“B”:2,“C”:2,“D”:1}