location object expected, location array not in correct format location object expected, location array not in correct format mongoose mongoose

location object expected, location array not in correct format


MongoDB 2d index requires the legacy coordinates pairs format, which is just an array of coordinates like [1, 2].

If you need GeoJSON support, please use the 2dsphere index.

userSchema.index({loc:'2dsphere'});