title: How does one represent MongoDB GeoJSON fields in a Mongoose Schema?
body: <p>MongoDB 2.4 allows the use of <a href="http://www.geojson.org/geojson-spec.html">GeoJSON</a> objects and a slew of <a href="http://docs.mongodb.org/manual/applications/2dsphere/">neat functions and indexes</a> that I'd like to use.</p>
  
  <p>It expects GeoJSON objects to be stored in the format like:</p>
  
  <pre><code>loc: {
    type: 'Polygon',
    coordinates: [[[-180.0, 10.0], [20.0, 90.0], [180.0, -5.0], [-30.0, -90.0]]]
  }
  </code></pre>
  
  <p>So in Mongoose one would think the schema would be defined like:</p>
  
  <pre><code>loc: { type: 'string', coordinates: [[['number']]] }
  </code></pre>
  
  <p>But this present two problems:</p>
  
  <ol>
  <li><p>having a field called "type" screws up Mongoose's schema parsing
  because it allows defining fields in the form field: { type: ,
  index: } etc. </p></li>
  <li><p>Mongoose does not like nested arrays.</p></li>
  </ol>
  
  <p>One way to overcome this is to simply use <code>mongoose.Schema.Types.Mixed</code>, however I feel that there has got to be a better way!</p>