如何解决猫鼬和GeoJSON:将LineString插入数据库
我为MongoDB中的Skiruns创建了一个 Schema :
const GeoSchema = new mongoose.Schema({
type: {
type: String,default: "LineString"
},coordinates: {
type: [[Number,Number]],index: "2dsphere"
}
});
const skirunSchema = new mongoose.Schema({
name: {
type: String
},difficulty: {
type: String
},geometry:GeoSchema
});
我想保存一条记录,例如:
{
"name": "Pista 3","geometry": { "type": "LineString","coordinates": [
[ 10.2387633,44.2841772 ],[ 10.2392284,44.2844519 ],[ 10.2397047,44.2845823 ],[ 10.2402091,44.2849467 ],]
}
我认为 coordinates.type 中存在问题,因此我无法存储记录。有人可以帮助我吗?
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。