PageRenderTime 13ms CodeModel.GetById 8ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/node_modules/mongoose/examples/geospatial/geoJSONSchema.js

https://bitbucket.org/coleman333/smartsite
JavaScript | 22 lines | 12 code | 3 blank | 7 comment | 0 complexity | 8098b2b7c50c789a1516a8cc39c3b7d6 MD5 | raw file
 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};