thoughts/node_modules/mongoose/examples/geospatial/geoJSONSchema.js
node_modules/mongoose/examples/geospatial/geoJSONSchema.jsRaw
1
2// import the necessary modules
3var mongoose = require('../../lib');
4var Schema = mongoose.Schema;
5
6// create an export function to encapsulate the model creation
7module.exports = function() {
8 // define schema
9 // NOTE : This object must conform *precisely* to the geoJSON specification
10 // you cannot embed a geoJSON doc inside a model or anything like that- IT
11 // MUST BE VANILLA
12 var LocationObject = new Schema({
13 loc: {
14 type: {type: String},
15 coordinates: []
16 }
17 });
18 // define the index
19 LocationObject.index({loc: '2dsphere'});
20
21 mongoose.model('Location', LocationObject);
22};