V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
• 请不要在回答技术问题时复制粘贴 AI 生成的内容
imherer
V2EX  ›  程序员

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

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