如何从结果查询mongodb数组中收集所有值

如何从结果查询mongodb数组中收集所有值,mongodb,find,Mongodb,Find,如何从结果查询mongodb Been数组中收集所有值,例如 当我执行这个查询“db.orbiats.find()”时,我得到如下结果: { "_id" : ObjectId("8686cdcdc89798797"), "name" : "Horse", "parent" : "animal", }, { "_id" : ObjectId("90808dsdd55679sss"), "name" : "Cow", "parent" : "anima

如何从结果查询mongodb Been数组中收集所有值,例如

当我执行这个查询“db.orbiats.find()”时,我得到如下结果:

{
    "_id" : ObjectId("8686cdcdc89798797"),
    "name" : "Horse",
    "parent" : "animal",
},
{
    "_id" : ObjectId("90808dsdd55679sss"),
    "name" : "Cow",
    "parent" : "animal",
},
{
    "_id" : ObjectId("908890dsddsd000808"),
    "name" : "Rose",
    "parent" : "flower",
}
如何查询以获得如下结果:

result = ["animal", "flower"]

如何做到这一点?

db.collections.distinct()操作应该可以做到这一点

db.organisms.distinct("parent");