-3
db.getSiblingDB("pilates").ball.find({ "list.Barcode.": "80196061999242"})
當我運行此查詢時,它會帶來此文檔。無法分配發現項目變量作爲數組
{
"Brand" : "Givi",
"list" : [
{
"Barcode" : [
"8019606199942"
]
}
..
}
]
.
...
.
}
但是當我運行此
db.getSiblingDB("pilates").ball.find({ "list.Barcode.": "80196061999242"}) .forEach(function(x){
print("m "+x.list.[0].Barcode);})
它給出了這樣的輸出
m undefined
或本
print("m "+x.list.(0).Barcode);})
它給這個
is not a function :
@(shell):4:16
[email protected]/mongo/shell/query.js:501:1
@(shell):1:1
此
print("m "+x.list.Barcode);})
給出了這樣的
m undefined
此 打印( 「M」 + X $條碼。);})
給出了這樣的
$ is undefined :
@(shell):4:3
[email protected]/mongo/shell/query.js:501:1
@(shell):1:1
爲什麼選擇c螞蟻得到了嗎?
請幫我們一個忙,並正確地格式化您的問題。閱讀一些代碼片段atm是一種痛苦。此外,你所有的代碼似乎都是JavaScript,你確定你正確使用了Java標籤嗎? – Thomas
除了需要成爲list [0]之外,還不清楚在查詢中是否帶有''list.Barcode。'',後綴爲** dot **'「。」'或者你的數據表示不正確。如果這是正在運行的實際查詢。如果是真正的查詢,那麼這將是'x.list [0] ['Barcode。'] [0]'在密鑰名稱中包含「點」 –