Answer the question
In order to leave comments, you need to log in
How to sort fields after applying $setUnion mongoDB?
There is a collection:
{
"_id" : ObjectId("5338ec2a5b5b71242a1c911c"),
"people" : [
{
"name" : "Vasya"
},
{
"age" : "30"
},
{
"weight" : "80"
}
],
"animals" : [
{
"dog" : "Sharick"
},
{
"cat" : "Barsik"
},
{
"bird" : "parrot"
}
]
},
{
"_id" : ObjectId("5338ec7f5b5b71242a1c911d"),
"people" : [
{
"name" : "Max"
},
{
"age" : "32"
},
{
"weight" : "78"
}
],
"animals" : [
{
"dog" : "Borbos"
},
{
"cat" : "Murka"
},
{
"bird" : "Eagle"
}
]
}
{
"result" : [
{
"_id" : ObjectId("5338ec2a5b5b71242a1c911c"),
"union" : [
{
"bird" : "parrot"
},
{
"name" : "Vasya"
},
{
"age" : "30"
},
{
"weight" : "80"
},
{
"dog" : "Sharick"
},
{
"cat" : "Barsik"
}
]
},
{
"_id" : ObjectId("5338ec7f5b5b71242a1c911d"),
"union" : [
{
"name" : "Max"
},
{
"age" : "32"
},
{
"weight" : "78"
},
{
"bird" : "Eagle"
},
{
"dog" : "Borbos"
},
{
"cat" : "Murka"
}
]
}
],
"ok" : 1
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question