我哈瓦3個文件的集合:MongoDB的查詢數組,其中的所有元素符合標準
{"users":[{"id":1,"gender":"male"},{"id:1,"gender":"male"},{"id":1,"gender":"male"}]}
{"users":[{"id":1,"gender":"male"},{"id:1","gender":"male"},{"id":1,"gender":"female"}]}
{"users":[{"id":1,"gender":"female"},{"id":1,"gender":"female"},{"id":1,"gender":"female"}]}
我想編寫一個查詢,每一個性別是男(users.gender:「男」),結果只得到:
{"users":[{"id":1,"gender":"male"},{"id:1,"gender":"male"},{"id":1,"gender":"male"}]}
到目前爲止,我能夠得到那些至少有一個字段符合標準的文件。所以我得到:
{"users":[{"id":1,"gender":"male"},{"id:1","gender":"male"},{"id":1,"gender":"female"}]}
{"users":[{"id":1,"gender":"female"},{"id":1,"gender":"female"},{"id":1,"gender":"female"}]}
有沒有辦法做到這一點?
請重新說明問題。這是無效的JSON,而這個例子沒有意義。 – mnemosyn 2014-09-30 10:18:55
這些文件沒有正確的json.Can你可以編輯你的問題來解決這個問題嗎? – 2014-09-30 11:25:18