我有这样的数据库。
计划= [starttype,starttime,collectionlist]
收藏夹列表是一组收藏夹
Collection = [collectionID,collectionCount,频道列表]
channellist是一组频道
Channel = [channelname,channelcolor]
我想使数据库成为猫鼬对象。
因此,我编写了以下代码,但无法检查子文档(ChannelList,CollectionList)。
输出时间表后如何查看收藏夹和频道列表?
var ChannelSchema = mongoose.Schema({
ADChannelName : String,
DisplayColor : String
});
var CollectionSchema = mongoose.Schema({
CollectionID : Number,
CollectionCount : Number,
chdata : [ChannelSchema]
});
var ScheduleSchema = mongoose.Schema({
StartType : Number,
StartDateTime : Date,
CollectionList : [CollectionSchema]
});
var Schedule = mongoose.model('schedule',ScheduleSchema);
var Collection = mongoose.model('collection',CollectionSchema);
var Channel = mongoose.model('channel',ChannelSchema);
var s = new Schedule();
s.StartType = 0;
s.StartDateTime = new Date(1970,05,10);
var c = new Collection();
c.CollectionID = 'a';
c.CollectionCount = 0;
var ch = new Channel();
ch.ADChannelName = 'b' ;
ch.DisplayColor = '#FF0000' ;
s.save(function(err){
if(err){
console.log(err);
}
else{
console.log(s);
}
});