我有一个新问题。我正在看这个shema fnd无法获得声明一个类似名字的键。
exports = module.exports = function(app, mongoose) {
var accountSchema = new mongoose.Schema({
user: {
id: { type: mongoose.Schema.Types.ObjectId, ref: 'User' },
name: { type: String, default: '' }
},
isVerified: { type: String, default: '' },
verificationToken: { type: String, default: '' },
name: {
first: { type: String, default: '' },
middle: { type: String, default: '' },
last: { type: String, default: '' },
full: { type: String, default: '' }
},
company: { type: String, default: '' },
phone: { type: String, default: '' },
zip: { type: String, default: '' },
status: {
id: { type: String, ref: 'Status' },
name: { type: String, default: '' },
userCreated: {
id: { type: mongoose.Schema.Types.ObjectId, ref: 'User' },
name: { type: String, default: '' },
time: { type: Date, default: Date.now }
}
},
statusLog: [mongoose.modelSchemas.StatusLog],
notes: [mongoose.modelSchemas.Note],
userCreated: {
id: { type: mongoose.Schema.Types.ObjectId, ref: 'User' },
name: { type: String, default: '' },
time: { type: Date, default: Date.now }
},
search: [String]
假设我在这里有user.name
和status.name
个密钥,而name
密钥本身有name.first
... name.full
个属性。 mongoose如何知道使用哪个name
?声明键名以及它可能导致什么问题的最佳做法是什么?