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

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

  •  
  •   imherer · Apr 18, 2017 · 1425 views
    This topic created in 3434 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   ·   2868 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 10:05 · PVG 18:05 · LAX 03:05 · JFK 06:05
    ♥ Do have faith in what you're doing.