2014-02-07 132 views
0

你好,我是一個MongoDB的小白, ,我想檢索後的評論列表:MongoDB的查詢子列表

{ 
    id:0, 
    ref:0, 
    type: 'image', 
    date: null, 
    title: 'this is my title', 
    comments:[ 
     { 
     user : 'myUser', 
     text : 'text' 
     }, 
     { 
     user : 'myUser2', 
     text : 'text2' 
     } 
} 

我怎麼能只查詢後的評論陣列?

我不想檢索其中的評論,但只有評論沒有別的?

這裏是我與jongo第一次嘗試:

Post.posts()找到( 「{REF:#}」,REF)。.projection( 「{評論:1}」)。如(帖子。 Commentaslass)

這不起作用:/,我想着將comments數組轉換爲Comment類型。 並使用投影只檢索評論部分...

回答