1
我正在使用Node.js.How可以在Mongoose模式上为Polygon配置2dsphere索引吗?Mongoose - 2dsphere index - howto
我试图与它:
location_2dsphere: {
type: { type: String }
, coordinates: []
},
但它不工作!
我正在使用Node.js.How可以在Mongoose模式上为Polygon配置2dsphere索引吗?Mongoose - 2dsphere index - howto
我试图与它:
location_2dsphere: {
type: { type: String }
, coordinates: []
},
但它不工作!
你这是怎么做到这一点
location_2dsphere: {
'type': { type: String },
coordinates: []
}
所以关键的是使第一type
是'type'
话,记得在你的领域建立一个2dsphere
指数!
在Mongoose中,当您想将字段命名为type
或任何其他保留字段时,只需使用圆括号强制字符串转换即可。