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

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

  •  
  •   imherer · Apr 18, 2017 · 1414 views
    This topic created in 3427 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   ·   Privacy   ·   Solana   ·   1432 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 24ms · UTC 17:00 · PVG 01:00 · LAX 10:00 · JFK 13:00
    ♥ Do have faith in what you're doing.