2

I want to add group by and order by in the same query, I have checked so many example where we can do this in mysql but how that will be done in objection. Currently I am doing this with foreach loop which is not good for large result.

logs = await logs.select('id','story_id').orderBy('id','desc'); 
                let ids:any[] = [];

                _.each(logs, (log:any)=>{
                    if(empty(ids[log.thred_id]))
                        ids[log.thred_id] = log.id;
                });

                log = await Logs.query().whereIn('id', _.values(ids)).orderBy('id','desc');

I want to show recent update of story only

HKumar
  • 1,535
  • 3
  • 13
  • 28

0 Answers0