title: Define a unique array of numbers in a mongoose Schema
body: <p>I want to store a load of arrays in mongoose on Node. I want to be sure those arrays contain a unique collection of numbers. Here's my Schema:</p>
  
  <pre><code>var schema = new Schema({
      array: { type: [Number], unique: true, required: true }
  });
  </code></pre>
  
  <p>It doesn't work. For example, creating and saving a couple of new db models that have a couple of (what I would call unique) arrays:</p>
  
  <pre><code>new Model({ array: [1,2] })
  new Model({ array: [0,2] })
  </code></pre>
  
  <p>...causes this:</p>
  
  <pre><code>E11000 duplicate key error index: test2.modes.$array_1  dup key: { : 1 }
  </code></pre>
  
  <p>..so it looks like 'unique' is checking every index in those arrays for uniqueness, rather than the entire array as being unique.</p>
  
  <p>Is there another way to do this in one step? Or do I have to perform a find on the db, say inside of a schema.pre('save', fn), to check the arrays are unique?</p>