One of the most common queries I use with mysql is:
select * from database where id in(1,5,3,2,4) order by field(id,1,5,3,2,4)
On a new project I’m using MongoDB, is there a similar query I can use? We use a separate search engine for actual searching and returns a list of ID’s in a specific order.
The equivalent MongoDB query would be:
But if you wanted to customize the
idorder beyond pure ascending you’d have to use the aggregation framework.