0
我在保存mongodb(Mongoose)中的json對象時遇到問題,所以當我插入一切正常,但是當我提出相同對象的請求時,Mongoose返回一個修改JSON。它像Mongoose自動完成Twitter領域,我不知道爲什麼。在Mongoose中保存/加載json對象之間的區別
這裏是我的代碼:
UserSchema = mongoose.Schema({
firstName: String,
lastName: String,
email: String,
salt: String,
hash: String,
twitter:{
id: String,
email: String,
name: String
},
facebook:{
id: String,
email: String,
name: String,
username: String,
photo: String,
gender: String
}
});
我救JSON在我的數據庫:
User.create({
email : profile.emails[0].value,
facebook : {
id: profile.id,
email: profile.emails[0].value,
name: profile.displayName,
username: profile.username,
photo: profile.photos[0].value,
gender: profile.gender
}
}, function(err, user){
if(err) throw err;
// if (err) return done(err);
done(null, user);
});
但我當貓鼬返回JSON。
貓鼬在JSON產生的場。推特:{} < ----
我不知道爲什麼,有人可以借我一隻手嗎?
我解決了你的答案的問題,我用JSON函數和它的工作很好。謝謝 – slorenzo