How do I get unique elements in this array?

前端 未结 6 1062
时光取名叫无心
时光取名叫无心 2021-01-30 06:11

Using Mongoid. Unfortunately, Mongoid does not allow for selecting unique / distinct! Have gotten these results. As you can see, there are 7 results. If you look carefully (at

6条回答
  •  庸人自扰
    2021-01-30 06:58

    Have you looked at this page?

    http://www.mongodb.org/display/DOCS/Aggregation#Aggregation-Distinct

    That might save you some time?

    eg db.addresses.distinct("zip-code");

提交回复
热议问题