假如我有如下两个 Collection :颜色和花,我要按颜色统计,对应的花的数量应该怎么写呢?用 mongoose 。
var color = new mongoose.Schema({ color: {type: String} }); var flower = new mongoose.Schema({ name:{type:String}, color: {type: mongoose.Schema.ObjectId,ref:'Color'} });