const userSchema = new Schema({
name:{type:String},
clubnumber:{type:String},
memo:[{
memos:{type:String}
}]
})數據結構如上,現在是想匹配name和clubnumber,來查詢庫下的所有memodb.userModel.findOne({name:name,clubnumber:clubnumber},(e,d)=>{ console.log(d.memo);
})小弟這樣寫的話,控制臺出來的數據是[
{ memos:xxx,id:xxxx},
{ memos:xxx1,id:xxxxx}
]小弟想得到的數據結構是
{memos1,memos2,memos3}//所有memos的一個數組小弟現在能想到用遍歷重新創建一個數組,但是有大神知道mongoose有什么操作能直接獲得這樣的嗎,感激不盡~
請問如何使用mongoose查詢內嵌數據呢
慕的地6264312
2018-07-23 21:57:35