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