2013-07-05 89 views
1

我正在使用Node.js.How可以在Mongoose模式上为Polygon配置2dsphere索引吗?Mongoose - 2dsphere index - howto

我试图与它:

location_2dsphere: { 
     type: { type: String } 
     , coordinates: [] 
    }, 

但它不工作!

回答

2

你这是怎么做到这一点

location_2dsphere: { 
    'type': { type: String }, 
    coordinates: [] 
    } 

所以关键的是使第一type'type'

话,记得在你的领域建立一个2dsphere指数!

在Mongoose中,当您想将字段命名为type或任何其他保留字段时,只需使用圆括号强制字符串转换即可。