当使用type
在嵌入式对象中命名的字段时,您需要使用一个对象来定义其类型,或者Mongoose认为您正在定义对象本身的类型。
因此,将您的架构定义更改为:
var simpleSchema = new Schema({
properties:{
name:String,
surname:String
},
location : {
type : { type: String },
coordinates : [ Number , Number ]
}
});