Monday 12 March 2018

Unknown geoJSON type — MongoDB (99% sure geoJSON type is correct 🤣)

This is part of my schema in my mongo Database: location: { type: { type: String, default: "Point" }, coordinates: [{ type: Number }], address: { type: "String", required: "You must supply coordinates" } } userSchema.index({ location: "2dsphere" }); And this is part of the data I'm saving."location": { "address": "NY, USA", "coordinates": [ "-74.0059728", "40.7127753" ] }, And apparently this is an unknown GeoJSON type.What is more infuriating is when I make a "new User" it saves the location data correctly. And understands the geoJSON type. Only when I "findOneAndUpdate" does it not understand the geoJSON type.I looked and the data I'm saving is the same in both circumstances.Massive thanks for any help. I'm tearing my hair out here.

Submitted March 12, 2018 at 01:15PM by harrydry

No comments:

Post a Comment