sql server有下列语句:
// 查找名字性别唯一的学生
select distinct name,sex from student
// 转换成MongoDB的话,我怎么把这种组合列去重,MongoDB好像只支持单个field的去重
db.student.distinct("name"); // 只支持一个field
db.student.distinct("name","sex"); // 错误的,不支持多个field的组合去重
有没有大神解决过类似问题,求指导.................
The method above is correct. MongoDB does not support combined deduplication. The example provided on the mongo official website only deduplicates a single field.
Official website example: http://docs.mongodb.org/manual/core/single-purpose-aggregation/