MongoDB 2.4 allows the use of GeoJSON objects and a slew of neat functions and indexes that I\'d like to use.
It expects GeoJSON objects to be stored in the format l
Mongoose now officially supports this.
In a nutshell, what you do is, for that schema, you use the typeKey
setting to tell mongoose to use a different key for type information. Here is an example:
var schema = new Schema({
// Mongoose interpets this as 'loc is an object with 2 keys, type and coordinates'
loc: { type: String, coordinates: [Number] },
// Mongoose interprets this as 'name is a String'
name: { $type: String }
}, { typeKey: '$type' }); // A '$type' key means this object is a type declaration
So now instead of declaring type info with the type
property, you use $type
. This works at the schema level so use it in the schemas that need it.