Location in mongoose, mongoDB
I fixed it myself.
I did this in my model:
loc : { type: {type:String}, coordinates: [Number]},
Underneath I made it a 2dsphere index.
eventSchema.index({loc: '2dsphere'});
And to add data to it:
loc: { type: "Point", coordinates: [ longitude, latitude ] },
Looks like your comment is correct (maybe), but the syntax for the index schemetype
here: http://mongoosejs.com/docs/api.html#schematype_SchemaType-index
It only accepts Object, Boolean, String
The correct syntax should be I think
var eventSchema = new Schema({
location: { type: [Number], index: { type: '2dsphere', sparse: true}}
)
based on the example in the docs.