title: MongoDB check types of attributes before insert
body: <p>I'm using mongoose to define the following schema:</p>
  
  <pre><code>var toySchema = new Schema({
      id: {type: String, required: true, unique: true},
      name: {type: String, required: true},
      price: Number
  });
  </code></pre>
  
  <p>I believed that when I inserted into the collection using db.toys.insert(), mongo would check to see that the type of each attribute matched the types in the schema, but it seems that it does not. For example, id should be a string, but I was able to insert a document with an integer id. How can I enforce the schema onto these inserts?</p>