title: Mongoose ObjectId : Error: Argument passed in must be a single String of 12 bytes or a string of 24 hex characters
body: <p>I am having difficulty creating my own ObjectId. I have two models:</p>
  
  <pre><code>const TableSchema = new mongoose.Schema ({ 
    .... 
    chairs: [{type: mongoose.Schema.Types.ObjectId, ref: 'ChairModel}] 
    .... 
  }) ;
  
  
  const ChairSchema = new mongoose.Schema ({ 
   .... 
   table: {type: mongoose.Schema.Types.ObjectId, ref: 'TableModel} 
   .... 
   }) ;
  </code></pre>
  
  <p>This pattern works for me ever time, when ObjectId is generated by mongoose.</p>
  
  <p>But when I generate a randomAlphaNum string:</p>
  
  <pre><code>let randomNum = makeRandom(24); //  1etdk0c86762e0fb12dptsli
  let TableId = mongoose.Types.ObjectId(randomNum);
  </code></pre>
  
  <p>I generate the error:</p>
  
  <blockquote>
    <p>Error: Argument passed in must be a single String of 12 bytes or a
    string of 24 hex characters</p>
  </blockquote>
  
  <p>How can I create a valid mongoose ObjectId from a simple alphaNumeric script generator?</p>