Monday, 13 March 2017

MongoError : Can't project geometry into spherical CRS

I am trying to store the location of an entity in Mongo. I seem to be having issues only w.r.t to a few locations that are entered. The error that I get is

MongoError: Can't extract geo keys:can't project geometry into spherical CRS: [ 26.1633829, 91.78194759999997 ]. Is there something wrong with the index. I am working on mongodb version 3.4

My schema is as follows

var mongoose = require('mongoose');
var Schema = mongoose.Schema;

var modelSchema = new mongoose.Schema({

email: {type: String, lowercase: true},
username: {type: String, unique: true, lowercase: true, index: true},
branchName: String,
address: {
    address1: String,
    address2: String,
    locality: String,
    pinCode: Number,
    sublocality_level_2: String,
    sublocality_level_1: String,
    localityName: String,
    administrative_area_level_2: String,
    administrative_area_level_1: String,
    country: String,
    postal_code: String,
    geo: {
        type: [Number],
        index: '2dsphere'
    }
},
branchPAN: String,
branchType: String,        
});

module.exports = mongoose.model('SampleModel', modelSchema);



via Rahul Ganguly

No comments:

Post a Comment