I'm new in Mongo DB and I'm using jenssegers Library in my Laravel Project. I have a table called 'table1' which has '_id','c1','c2','c3','created_at' columns. I need to convert bellow SQL query to mongo db.
select *, count(c3) as total from
(select * from table1
where c1 in ('1', '32', '6', ...)
order by created_at desc) as temp
group by c2 order by created_at desc
I need to select all the column including '_id'. I need only rows containing maximum created_at value by 'order by' when grouped by c2 column and order again result rows by that created_at column.
I found this answer but My question is little bit more complex I think: https://stackoverflow.com/a/24143255/3386509
And this could be useful and related to my problem: http://blog.chomperstomp.com/how-to-order-by-before-group-by-with-mysql/