V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
imherer
V2EX  ›  程序员

请教 mongoose 分组统计该怎么写呢

  •  
  •   imherer · 2017-04-18 10:51:30 +08:00 · 969 次点击
    这是一个创建于 2730 天前的主题,其中的信息可能已经有所发展或是发生改变。

    假如我有如下两个 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'}
    });
    
    目前尚无回复
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   3024 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 28ms · UTC 11:49 · PVG 19:49 · LAX 04:49 · JFK 07:49
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.