我有三个关系模型:
公共/模型/ customer.json
"relation": {
"fundSource": {
"type": "hasMany",
"model": "CreditCard",
"foreignKey": "",
"through": "fundingEntities"
}
}
公共/模型/资金-entities.json
"relations": {
"customer": {
"type": "belongsTo",
"model": "Customer",
"foreignKey": "CustomerId"
},
"creditCards": {
"type": "hasMany",
"model": "CreditCard",
"foreignKey": ""
}
}
公共/模型/信用card.json
"relations": {
"customer": {
"type": "hasAndBelongsToMany",
"model": "BoomCustomer"
}
}
客户可以通过fundSource(信用卡,PayPal等)向其账户加载资金
如果不存在,我试图将fundSource添加到客户:
customer.fundSource.create(data, function(err,res){
console.log(err);
}
但是控制台说undefined不是一个函数。
我怎样才能做到这一点?我正在使用mongoDB数据源。