0
我在我的Mongoose中嵌套了文檔/模式,計劃使用不同的模式來分隔關注點。Mongo(ose)返回對象數組對象
數據在我的數據庫中看起來都是正確的,但是,在試圖將其拉出時,我只能獲取Object對象的數組。
下面是從搬運工-撰寫控制檯和上返回用戶的console.log
timr-app | [ { _id: 595be74705426a0001f68c7a,
timr-app | name: 'Stu Sklinar',
timr-app | __v: 0,
timr-app | events: [ [Object], [Object], [Object] ] }
用戶架構:
var mongoose = require('mongoose');
var EventSchema = require('./event').schema;
// define the schema for our user model
var userSchema = mongoose.Schema({
facebookUserId: String,
token: String,
name: String,
events: [EventSchema]
});
// create the model for users and expose it to our app
module.exports = mongoose.model('User', userSchema);
事件架構:
var mongoose = require('mongoose');
var Schema = mongoose.Schema;
var CourseSchema = require('./course.js').schema;
var EventSchema = new Schema({
course: CourseSchema,
date: Date,
time: String
}, {
bufferCommands: false,
timestamps: true
});
module.exports = {
EventSchema,
}
使用'console.dir(myObject的,{深度:3,顏色:真});' – nmanikiran