gpt4 book ai didi

javascript - 在 Mongoose 模式中添加带有破折号字符的字段

转载 作者:行者123 更新时间:2023-12-01 02:36:34 25 4
gpt4 key购买 nike

我想向其中包含破折号字符 (-) 的架构添加一个字段。 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com