Monday, 29 May 2017

Nodes and mongoose

How to I render data from multiply collections to ejs view? Example:

 Route. get('/',function(req,res,){
res.render{
Col1: col1Data,
Col2: col2Data
}
});

I used population where I have two mongoose schema and the child schema makes reference to d parent: //parent schema

UserSchema = mongoose.Schema({
username:String,
email:String
});

UserStatus = mongoose.Schema({
user status : String,
_creator: {type: mongoose.Schema.ObjectId, ref: 'user'}
});



via Adrian

No comments:

Post a Comment