title: mongo ref returning null in database?
body: <p>I am working on a react project using ther MERN stack. When the favourite object is created in the database userFrom returns null. While everything is present. In the user model I had no issue referencing role to user. I tried removing the reference to the role model from user and trying it  again but I still had the same issue.</p>
  <p>favourites model</p>
  <pre><code>const mongoose = require('mongoose');
  
  const Favourite = mongoose.model(
      &quot;Favourite&quot;,
      new mongoose.Schema({
          movieId : String,
          movieTitle: String,
          movieImg: String,
          userFrom:[
              {
                  type: mongoose.Schema.Types.ObjectId,
                  ref: &quot;User&quot;
              }
          ]
      })
  
  )
  </code></pre>
  <p>user model</p>
  <pre><code>const mongoose = require(&quot;mongoose&quot;);
  
  const User = mongoose.model(
    &quot;User&quot;,
    new mongoose.Schema({
      username: String,
      email: String,
      password: String,
      roles: [
        {
          type: mongoose.Schema.Types.ObjectId,
          ref: &quot;Role&quot;
        }
      ]
    })
  );
  
  module.exports = User;
  </code></pre>
  <p>role model</p>
  <pre><code>const mongoose = require(&quot;mongoose&quot;);
  
  const Role = mongoose.model(
    &quot;Role&quot;,
    new mongoose.Schema({
      name: String
    })
  );
  
  module.exports = Role;
  </code></pre>
  <p>favourite.routes</p>
  <pre><code>const express =  require('express');
  const router = express.Router();
  const { authJwt } = require(&quot;../middlewares&quot;);
  const Favourite = require(&quot;../models/favourite.model&quot;);
  
      router.use(function(req, res, next) {
        res.header(
          &quot;Access-Control-Allow-Headers&quot;,
          &quot;x-access-token, Origin, Content-Type, Accept&quot;
        );
        next();
  });
  
  
  router.post(&quot;/favouriteNumber&quot;, [authJwt.verifyToken], (req, res) =&gt; {
      Favourite.find({&quot;movieId&quot;: req.body.movieId})
          .exec((err, favourite) =&gt; {
              if(err) return res.status(400).send(err)
              res.status(200).json({success: true, favouriteNumber: favourite.length})
          })
  })
  
  router.post(&quot;/favourited&quot;, [authJwt.verifyToken], (req, res) =&gt; {
      Favourite.find({&quot;movieId&quot;: req.body.movieId, &quot;userFrom&quot;: req.body.userFrom})
          .exec((err, favourite) =&gt; {
              if(err) return res.status(400).send(err) 
  
              let result = false;
              if(favourite.length !== 0) {
                  result = true
              }
  
              res.status(200).json({success: true, favourited: result});
  
  
          })
  })
  
  router.post(&quot;/addToFavourite&quot;, [authJwt.verifyToken], (req, res) =&gt; {
      
      const favourite = new Favourite(req.body)
  
      favourite.save((err, doc) =&gt; {
          if(err) return res.json({success: false, err})
          return res.status(200).json({success: true, doc})
      })
  })
  
  router.post(&quot;/removeFavorite&quot;, [authJwt.verifyToken], (req, res) =&gt; {
      
      Favourite.findOneAndDelete({movieId: req.body.movieId, userFrom: req.body.userFrom})
          .exec((err, doc) =&gt; {
              if(err) return res.json({success: false, err})
              return res.status(200).json({success: true, doc})
          })
  })
  module.exports = router;
  </code></pre>