I have an aggregation pipeline that returns 20 tuples with known _id’s:
[ { _id: 'AA', value: 5 },
{ _id: 'CD', value: 2 },
How to create a pipeline stage to order them in an arbitrary order?
For example ‘CD’, ‘AA’, ‘EF’, ‘BC’.
I have an aggregation pipeline that returns 20 tuples with known _id’s:
[ { _id: 'AA', value: 5 },
{ _id: 'CD', value: 2 },
How to create a pipeline stage to order them in an arbitrary order?
For example ‘CD’, ‘AA’, ‘EF’, ‘BC’.
2
Answers
Similar to Takis' answer.
Query1
*i don’t know if this is the optimal way to do it, but it works
Playmongo
Query2
_id
from the array that defines the orderPlaymongo