0
我有一個關於node orm2 hasMany關聯的問題,我的模型定義是這樣的。node orm2 hasmany association
模式/ Channel.js
var model = db.define('channels', Channel, ChannelOptions);
var Channel = {
channel_name : String,
channel_email : String,
channel_id : String,
views : Number
};
var ChannelOptions = {
id : "channel_id",
methods: {
my_details : function (err) {
return this.channel_id +' '+ this.channel_name + ' ' + this.views;
}
}
};
模式/ network.js
var model = db.define('networks', Network, NetworkOptions);
var Channel = require('../schemas/Channel')(db);
model.hasMany('channels', Channel, {}, {autoFetch:true});
model.sync()
db.sync(function(){
console.log('DB SYNCHED');
});
var Network = {
network_id : Number,
name : String,
username : String,
logo : String,
website : String
};
var NetworkOptions = {
id : "network_id",
methods: {
}
};
它創造了networks_channels表,我有一個網絡ID和填充的channelID它。它正在與屬性(頻道)進行響應,但它是空的。 有什麼缺失?