• 请不要在回答技术问题时复制粘贴 AI 生成的内容
imherer
V2EX  ›  程序员

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

  •  
  •   imherer · Apr 18, 2017 · 1274 views
    This topic created in 3339 days ago, the information mentioned may be changed or developed.

    假如我有如下两个 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'}
    });
    
    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1386 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 36ms · UTC 17:09 · PVG 01:09 · LAX 10:09 · JFK 13:09
    ♥ Do have faith in what you're doing.