我已经有了这样的文档集合:
{"name": "apple", "cnt": 10}
{"name": "orange", "cnt": 15}
{"name": "banana", "cnt": 12}
{"name": "grapefruit", "cnt": 2}
我想将它们转换为一个文档数组,它应该是这样的:
[
{"name": "apple", "cnt": 10},
{"name": "orange", "cnt": 15},
{"name": "banana", "cnt": 12},
{"name": "grapefruit", "cnt": 2}
]
关于我该怎么做的任何建议? 提前谢谢你
Mongo group and push: pushing all fields
我已经尝试过推送编辑器
{ $group : {fish: { $push : "$$ROOT" }}}
但徒劳无功