示例数据:
{"_id" : ObjectId("5c9d8cc3161d6c257c021340"),"email" : "123@123com"
}
{"_id" : ObjectId("5ca2bc4a54bc0f2fa07b1541")"email" : "234@234.com"
}
{"_id" : ObjectId("5ca2cb7a9f464a1710a3f28c"),"email" : "345@345.com"
}
执行:
db.getCollection('users').distinct('email')
结果:
["123@123.com","234@234.com","345@345.com"
]