Hacker News new | comments | show | ask | jobs | submit login

The example would be much clearer as an aggregation query. Roughly:

    db.demo.aggregate([
        { $match: { score: { $gt: 0 },
                    person: { $in: ["bob","jake"] }}},
        { $group: { _id: "person",
                    sumscore: { $sum: "$score" },
                    avgscore: { $avg: "$score" },
                    minscore: { $min: "$score" },
                    maxscore: { $max: "$score" },
                    count: { $sum: 1 }}}
    ]);



Guidelines | FAQ | Support | API | Security | Lists | Bookmarklet | DMCA | Apply to YC | Contact

Search: