询问:
db.trace.aggregate([
{$unwind:"$likes"},
{ $group : { _id : {"name" : "$name"} } }
]);
蒙戈集合:
"likes" : [
{
"category" : "test1",
"name" : "test1",
"created_time" : "2014-01-08T20:50:02+0000",
"id" : "14157481053234234"
},
{
"category" : "Publisher",
"name" : "City Pulse",
"created_time" : "2014-01-06T22:46:19+0000",
"id" : "169217625001"
}
]
错误:
{
"errmsg" : "exception: $unwind: value at end of field path must be an array",
"code" : 15978,
"ok" : 0
}
得到对象不是数组的错误,但它是。
最佳答案
可能在一个或多个文件中 likes
不是数组。
检查它: db.trace.find( { $where : "!Array.isArray(this.likes)" } )
。
关于mongodb - "errmsg": "exception: $unwind: value at end of field path must be an array",我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/22137451/