title: Passing model parameters into a mongoose model
body: <p>I have a mongoose model that has an association with a user model e.g. </p>
  
  <pre><code>var exampleSchema = mongoose.Schema({
     name: String,
     &lt;some more fields&gt;
     userId: { type:mongoose.Schema.Types.ObjectId, ref: 'User' }
  });
  
  var Example = mongoose.model('Example', userSchema)
  </code></pre>
  
  <p>When I instantiate a new model I do:</p>
  
  <pre><code>// the user json object is populated by some middleware 
  var model = new Example({ name: 'example', .... , userId: req.user._id });
  </code></pre>
  
  <p>The model's constructor takes a lot of parameters which has become tedious to write and refactor when the schema changes. Is there way of doing something like:</p>
  
  <pre><code>var model = new Example(req.body, { userId: req.user._id });
  </code></pre>
  
  <p>Or is the best way to create a helper method to generate a JSON object or even attach the userId to the request body? Or is there way that I haven't even thought of?</p>