You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

22 lines
613 B

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