请教mongoose分组统计该怎么写呢
发布于 7 年前 作者 im-here 2484 次浏览 来自 问答

假如我有如下两个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'}
});
回到顶部