我的架构:
Account: mongoose.model('Account', new Schema({
account_name: String,
company: String,
notes: String,
contact_info: [this.ContactInfo]
})),
ContactInfo: mongoose.model('ContactInfo', new Schema({
name: String,
email: String,
phone: String,
notes: String
}))
但是,当我尝试对 contact_info 执行任何操作时,它说这些方法不存在。
var c = new ContactInfo...);
var a = new Account(...);
a.contact_info.create(c); //error, create doesn't exsit
a.contact_info.push(c); //works
a.contact_info.id(...).remove(); //id doesn't exist
难道我做错了什么?
我的完整代码在这里(不多):https ://github.com/nycitt/node-survey-builder-api-server/blob/master/accounts.js
顺便说一下,我正在接收来自 Backbone.js 的输入