猫鼬和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 (将#修改为@)