# Populate subdocument mongoose

**URL:** <https://forum.freecodecamp.org/t/populate-subdocument-mongoose/275073>\
**Category:** General\
**Created:** [May 3, 2019, 1:05am UTC](https://forum.freecodecamp.org/t/populate-subdocument-mongoose/275073 "2019-05-03T01:05:58Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![lubodrinka](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/lubodrinka/32/158618_2.png) [@lubodrinka](https://forum.freecodecamp.org/u/lubodrinka)\
**Post date:** [May 3, 2019, 1:05am UTC](https://forum.freecodecamp.org/t/populate-subdocument-mongoose/275073/1 "2019-05-03T01:05:58Z")

</div>

I have a Person and Video model.  
Person had subdoc with social profils.  
According [https://mongoosejs.com/docs/populate.html](https://mongoosejs.com/docs/populate.html)  
I want when Video quering populate with ref id.

But I get author: null

```auto
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' });
          }

        });

```

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [January 17, 2021, 9:50am UTC](https://forum.freecodecamp.org/t/populate-subdocument-mongoose/275073/2 "2021-01-17T09:50:49Z")

</div>

Closed on January 17, 2021, 9:50am UTC


