title: Writing A Mongoose Plug In- plugin() a method?
body: <p>I am interested in writing a mongoose plug in to make all fields required. I know there are other ways to do this, but I like the idea of writing my own plug in. </p>
  
  <p>From docs <a href="http://mongoosejs.com/docs/plugins" rel="nofollow">http://mongoosejs.com/docs/plugins</a>:</p>
  
  <pre><code>// game-schema.js
  var lastMod = require('./lastMod');
  var Game = new Schema({ ... });
  Game.plugin(lastMod, { index: true });
  </code></pre>
  
  <p>but when I create a model from my schema and look at the properties, I don't see a plugin() method:</p>
  
  <pre><code>var mongoose = require('mongoose');
  var CpuSchema = require("../schemas/cpu");
  
  var Cpu = mongoose.model('Cpu', CpuSchema);
  console.log(Cpu);
  
  module.exports = Cpu;
  </code></pre>
  
  <hr>
  
  <pre><code>one@demo ~/cloudimageshare-monitoring/project $ node /home/one/cloudimageshare-monitoring/project/app/data/models/cpu.js  
  { [Function: model]
    base: 
     { connections: [ [Object] ],
       plugins: [],
       models: { Cpu: [Circular] },
       modelSchemas: { Cpu: [Object] },
       options: { pluralization: true } },
    modelName: 'Cpu',
    model: [Function: model],
    db: 
     { base: 
        { connections: [Object],
          plugins: [],
          models: [Object],
          modelSchemas: [Object],
          options: [Object] },
       collections: { cpus: [Object] },
       models: {},
       replica: false,
       hosts: null,
       host: null,
       port: null,
       user: null,
       pass: null,
       name: null,
       options: null,
       otherDbs: [],
       _readyState: 0,
       _closeCalled: false,
       _hasOpened: false,
       _listening: false },
    discriminators: undefined,
    schema: 
     { paths: 
        { timeStamp: [Object],
          avaiable: [Object],
          status: [Object],
          metrics: [Object],
          _id: [Object],
          __v: [Object] },
       subpaths: {},
       virtuals: { id: [Object] },
       nested: {},
       inherits: {},
       callQueue: [],
       _indexes: [],
       methods: {},
       statics: {},
       tree: 
        { timeStamp: [Object],
          avaiable: [Function: Boolean],
          status: [Function: String],
          metrics: [Object],
          _id: [Object],
          id: [Object],
          __v: [Function: Number] },
       _requiredpaths: undefined,
       discriminatorMapping: undefined,
       _indexedpaths: undefined,
       options: 
        { id: true,
          noVirtualId: false,
          _id: true,
          noId: false,
          read: null,
          shardKey: null,
          autoIndex: true,
          minimize: true,
          discriminatorKey: '__t',
          versionKey: '__v',
          capped: false,
          bufferCommands: true,
          strict: true,
          pluralization: true },
       _events: {} },
    options: undefined,
    collection: 
     { collection: null,
       opts: { bufferCommands: true, capped: false },
       name: 'cpus',
       conn: 
        { base: [Object],
          collections: [Object],
          models: {},
          replica: false,
          hosts: null,
          host: null,
          port: null,
          user: null,
          pass: null,
          name: null,
          options: null,
          otherDbs: [],
          _readyState: 0,
          _closeCalled: false,
          _hasOpened: false,
          _listening: false },
       queue: [ [Object] ],
       buffer: true } }
  </code></pre>
  
  <p>Here on the model, I don't see a plugin() method. </p>