我在mongodb中有一个架构,如
var schema = new mongoose.Schema({
agentCode: String,
data: {
type: Object,
profDtl: {
education: String
}
});
现在我想在desgnName
profDtl
var schema = new mongoose.Schema({
agentCode: String,
data: {
type: Object,
profDtl: {
desgnName: String, // trying to add new property
education: String
}
});
但它没有反映在数据库中
答案 0 :(得分:0)
我得到了一个解决方案,每当在mongodb架构中添加新属性时,它都需要一个默认值来反映新条目
表示例如:
var schema = new mongoose.Schema({
agentCode: String,
data: {
type: Object,
profDtl: {
desgnName: {
type: String,
default: ""
},
education: String
}
});
现在工作正常