I have a Person and Video model.
Person had subdoc with social profils.
According https://mongoosejs.com/docs/populate.html
I want when Video quering populate with ref id.
But I get author: null
let loginProfileSchema = new Schema({ social: String, name: String});
let personschema = new Schema({ ip: [String], user: [loginProfileSchema], videos: { type: Schema.Types.ObjectId, ref: 'Video' }});
global.Video = mongoose.model('Video', new Schema({author: { type: Schema.Types.ObjectId, ref: 'videoappperson' },urlImage: String, visitorsIp: [String], videoName: String}
creating of person let newchild = { _id: new mongoose.Types.ObjectId(), social: 'github', name: req.user.username}
const newdoc = new Person({ip: req.ip, user: newchild });
newdoc.save().then(() => console.log('new Person save' + newdoc));
the VIdeo is saved
const newdoc = new Video({author:mongoose.Types.ObjectId(User_id),videoName: videoName, urlVideo: urlVideo, urlImage:urlImage})
and query
Video.find({})
.populate(
'author'
)
.exec(
function (err, docs) {
if (err) errorhandler(err);
if (docs) {
console.log(docs);
*/ res.render('grid', { v: docs, acBtn: 'allvideo' });
}
});