下面是我收集的文件MongoDB的錯誤
[0] => Array
(
[Patent] => Array
(
[allocation] => Array
(
[1] => Array
(
[r_1_a] => 17
)
)
[pn] => US20120101874A1
[id] => 52fb18775f44eaaf0a8b462a
)
)
我試圖用$這個查詢放鬆操作:
db.patents.aggregate([{'$unwind':'$allocation'}]);
這是給我的例外:
Error: Printing Stack Trace
at printStackTrace (src/mongo/shell/utils.js:37:15)
at DBCollection.aggregate (src/mongo/shell/collection.js:897:9)
at (shell):1:12
Wed Feb 12 16:31:09.515 aggregate failed: {
"errmsg" : "exception: $unwind: value at end of field path must be an array",
"code" : 15978,
"ok" : 0
} at src/mongo/shell/collection.js:898
幫我解決這個問題,因爲我在數組上應用$ unwind。
如果你將文檔顯示爲由mongo shell代替而不是PHP轉儲,那麼這可能會更好。另外,你是否確定**所有**分配元素**都是**數組?這部分是有據可查的。 –
'「分配」:{「1」:{「r_1_a」:17}},'。這裏是代表專利收集 – user199354
'分配'不是給你添加在你的評論中的數組。這是一個名爲'「1」'的字段的子文檔。您的文檔保存代碼不會保存爲數組。 – WiredPrairie