【发布时间】:2013-04-30 16:01:50
【问题描述】:
如何在猫鼬中索引数组元素,这是我在架构中尝试的,但它不起作用
locations : [{
loc: { type: [Number], index: '2d'}
}]
【问题讨论】:
-
看起来不错。有什么不好的地方?
如何在猫鼬中索引数组元素,这是我在架构中尝试的,但它不起作用
locations : [{
loc: { type: [Number], index: '2d'}
}]
【问题讨论】:
[Number] 表示数字数组.... 如果想要一个没有定义类型的数组,你可以像这样使用混合类型:
loc: { type: [], index: '2d'}
或者
loc: { type: Schema.Types.Mixed, index: '2d'}
顺便说一下,这是一个 documentation 用于猫鼬模式类型
【讨论】: