title: mongoose.Schema.Types.ObjectId is giving an empty array when console.logged
body: <p>This is my table schema</p>
  
  <pre><code>var mongoose=require("mongoose");
  
  var tableSchema=new mongoose.Schema({
    tName:String,
    keys:[
      {
        type:mongoose.Schema.Types.ObjectId,
        ref:"key"
      }
    ],
    fields:[
      {
        type:mongoose.Schema.Types.ObjectId,
        ref:"field"
      }
    ]
  })
  module.exports=mongoose.model("table",tableSchema);
  </code></pre>
  
  <p>----Key Schema</p>
  
  <pre><code>var mongoose=require("mongoose")
   var keySchema=new mongoose.Schema({
     name:[String],
     value:[String]
   })
  module.exports=mongoose.model("key",keySchema);
  </code></pre>
  
  <p>---field Schema</p>
  
  <pre><code>var mongoose=require("mongoose")
  
   var fieldSchema=new mongoose.Schema({
     name:[String],
     value:[String]
   })
  module.exports=mongoose.model("field",fieldSchema);
  </code></pre>
  
  <p>----How I Pushed into</p>
  
  <pre><code>  app.post("/table/:id/value",function(req,res){
        var Key={
          name:req.body.key,
          value:req.body.keyValue
        }
        var Field={
          name:req.body.field,
          value:req.body.fieldValue
        }
        table.findById(req.params.id,function(err,foundTable){
          if(err){
            console.log(err)
          }
          else{
            console.log(foundTable)
            key.create(Key,function(err,createKey){
              foundTable.keys.push(createKey)
              console.log(createKey)
            })
            field.create(Field,function(err,createField){
              foundTable.fields.push(createField)
              console.log(createField)
            })
            foundTable.save();
            console.log(foundTable);
              res.redirect("/table/"+req.params.id)
          }
        })
  })
  </code></pre>
  
  <p>ObjectId are not being refernced
  <a href="https://i.stack.imgur.com/IGh3D.png" rel="nofollow noreferrer">Here is the Image that prints the table</a></p>
  
  <p>How I populated the table</p>
  
  <pre><code>app.get("/table/:id",function(req,res){
    table.findById(req.params.id).populate("keys").populate("fields").exec(function(err,foundTable){
      if(err){
        console.log(err)
        res.redirect("/")
      }
      else{
        console.log(foundTable);
        res.render("show",{table:foundTable})
      }
    })
  })
  </code></pre>
  
  <p>I Dont know where I had gone wrong,
  everything seems to be fine but
  the objected is not referenced when printed and
  it is not being populated</p>
  
  <p>How it should be printed reference: <a href="https://bezkoder.com/mongoose-one-to-one-relationship-example/" rel="nofollow noreferrer">https://bezkoder.com/mongoose-one-to-one-relationship-example/</a></p>
  
  <p><strong>This is an example:</strong>
  1st schema</p>
  
  <pre><code>const mongoose = require("mongoose");
  
      const Customer = mongoose.model(
        "Customer",
        new mongoose.Schema({
          name: String,
          age: Number,
          gender: String
        })
      );
  
      module.exports = Customer;
  </code></pre>
  
  <p>2nd schema</p>
  
  <pre><code> const mongoose = require("mongoose");
  
      const Identifier = mongoose.model(
        "Identifier",
        new mongoose.Schema({
          cardCode: String,
          customer: {
            type: mongoose.Schema.Types.ObjectId,
            ref: "Customer"
          }
        })
      );
  
      module.exports = Identifier;
  </code></pre>
  
  <p>How it should be printed</p>
  
  <pre><code>{
     _id : ObjectId("5da000be062dc522eccaedeb"),
     cardCode : "5DA000BC06",
     customer : ObjectId("5da000bc062dc522eccaedea"),
     __v : 0
  }
  </code></pre>
  
  <p>How it should be populated</p>
  
  <pre><code> [ { _id: 5da135bf61a1dd3e9c2a6e82,
      cardCode: '5DA135BD61',
      customer:
       { _id: 5da135bd61a1dd3e9c2a6e81,
         name: 'bezkoder',
         age: 29,
         gender: 'male',
         __v: 0 },
      __v: 0 } ]
  </code></pre>