0
我有一個集合如下, 如何查詢一個字段並獲取貓鼬的特定字段?
我想獲得特定國家的城市。應該查詢什麼?
這是我試過的。
db.getCollection('_event').find([
{$match: {}},
{$project: {
cities: {
$filter: {
input: 'city',
as: 'r',
cond: {$eq: ['$$r.country', 'Portugal']}
}
}
}}
])
可能重複[Mongoose,選擇一個特定的字段與查找](http://stackoverflow.com/questions/24348437/mongoose-select-a-specific-field-with-find) – ippi
圖像是有用的一篇文章,但**確保沒有他們的帖子仍然清晰**。不要顯示數據格式的屏幕截圖,而是直接複製並粘貼或將實際數據輸入到帖子中。 參見http://meta.stackoverflow.com/questions/303812/discourage-screenshots-of-code-and-orrors –