0
我有以下模式如何從MongoDB中選擇單個列?
var usersSchema = mongoose.Schema({
uname : {type : String , unique: true},
email : {type : String},
logintype : {type : String},
password : String,
status : String,
hash : String,
social: {},
games: Object,
os: String,
friends: Object,
msges:Object
});
我想獲取特定用戶的msges
的用戶表。我有用戶名。目前這是我在做什麼
var getMessages = function(user){
global.users.find({"uname" : uname},
{"friends.friendUname":1,_id:0},
function(err,doc){
if(err){
callback(false,err,"",null);
}else{
callback(true,null,"",doc);
}
}
);
}
但我不想要所有的領域。任何幫助?
問請搜索之前,http://stackoverflow.com/questions/24348437/mongoose-select-a-specific-field-with-find –
的 重複發佈此問題之前,我已經搜索過。我似乎無法做到。有任何想法嗎? –