bloomy bloomy - 1 month ago 7
Javascript Question

Mongo findOne function for node does not return geometrty data

I am having some trouble trying to get mongo to correctly return geometry data.

When I run

db.shapes_houses.findOne({ 'properties.IDENTIFCAT': '0373100000004063' }
function directly in the mongo shell I get the correct results I need:



{
"_id" : ObjectId("576bfc6d669adc5c2556676b"),
"type" : "Feature",
"properties" : {
"IDENTIFCAT" : "0373100000004063",
"VOETPRINT" : 62.423811
},
"geometry" : {
"type" : "Polygon",
"coordinates" : [
[
[
105719.1640625,
515371.03125
],
[
105715.9921875,
515375.4375
],
[
105722.84375,
515380.375
],
[
105725.3359375,
515382.15625
],
[
105728.5,
515377.75
],
[
105726.015625,
515375.96875
],
[
105719.1640625,
515371.03125
]
]
]
}
}





However when I run the
db.Object.findOne({ 'properties.IDENTIFCAT': '0373100000004063' }).exec()
through my node app I don't get any of the geometry data, only id, type and properties are returned.

Does anybody have any idea why this might be happening?? I am tearing my hair out over it.

Thanks!

Answer

The solution was to add the typekey option to exports.schema.geometry as explained here http://mongoosejs.com/docs/guide.html#typeKey