title: How to set ObjectId as a data type in mongoose
body: <p>Using node.js, mongodb on mongoHQ and mongoose. I'm setting a schema for Categories. I would like to use the document ObjectId as my categoryId.</p>
  
  <pre><code>var mongoose = require('mongoose');
  
  var Schema = mongoose.Schema,
      ObjectId = Schema.ObjectId;
  var Schema_Category = new Schema({
      categoryId  : ObjectId,
      title       : String,
      sortIndex   : String
  });
  </code></pre>
  
  <p>I then run</p>
  
  <pre><code>var Category = mongoose.model('Schema_Category');
  var category = new Category();
  category.title = "Bicycles";
  category.sortIndex = "3";
  
  category.save(function(err) {
    if (err) { throw err; }
    console.log('saved');
    mongoose.disconnect();     
  });
  </code></pre>
  
  <p>Notice that I don't provide a value for categoryId. I assumed mongoose will use the schema to generate it but the document has the usual "_id" and not "categoryId". What am I doing wrong?</p>