0
使用mongoose schema.types.Mixed來讀取現有集合不能識別鍵/值對,控制檯只顯示「_id」,但當試圖訪問另一個鍵/值對時,值我得到一個未定義的Mongoose Schema.Types.Mixed not working
var UserSchema1 = new mongoose.Schema({ key: {}}); var UserSchema2 = new mongoose.Schema({ userID: Number, userName: String, password: String}); var User = mongoose.model('user', UserSchema1,'info'); router.get('/', function(req, res) { User.find({}, function(err, docs) { var s = docs; console.log(s[0].userName); console.log(s[0]._id); res.render('userinfo', {users : docs}); }); }); ---- OUTPUT ---- **UserSchema1** - **UserSchema2** console.log(s[0].userName); undefined mongo console.log(s[0]._id); 241245j23j6l26l6 afa88asf8989asfa --jade.js-- ul each user in users li #{user._id} li #{user['userName']} Shows only li with the _id but it creates empty li supposedly for user.name