我想向其中包含破折号字符 (-
) 的架构添加一个字段。 Mongoose 不允许这样做。这可能吗?
var mySchema = new Schema({
family-name: {
type: String,
default: ''
}
});
最佳答案
只需在属性名称周围添加引号:
var mySchema = new Schema({
'family-name': {
type: String,
default: ''
}
});
关于javascript - 在 Mongoose 模式中添加带有破折号字符的字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47860042/