我想使用Mongodb和NodeJS在数据库中存储地理位置
message:
'Cast to Embedded failed for value "[72.591760, 23.014510]" at path "geometry"',
name: 'CastError',
stringValue: '"[72.591760, 23.014510]"',
kind: 'Embedded',
value: '[72.591760, 23.014510]',
path: 'geometry',
reason: [MongooseError] } },
_message: 'userLocation validation failed',
name: 'ValidationError' }
答案 0 :(得分:0)
以此形式存储位置
"location_point" : {
"coordinates" : [
-95.712891,
37.09024
],
"type" : "Point"
}
-95.712891 - Long
37.09024 -Lat
答案 1 :(得分:0)
const userLocationData = {
name,
geometry: {
type: 'Point',
coordinates: JSON.parse(geometry)
}
};