Transcript raw sql request to Lucid


#1

Please can anyone help me transcript the raw sql request below to Lucid model?
I’d like to make the same request but with Lucid in another words!

let conversations =  await Database.raw(
           `SELECT * FROM messages msg INNER JOIN (
             SELECT max(created_at) created_at FROM messages GROUP BY to_id ORDER BY created_at
           ) m2
           ON msg.created_at = m2.created_at WHERE from_id = ? ORDER BY updated_at DESC`, [auth.user.id]
         )

#2

Can you be atleast less lazy and share the actual sql query by typing it out?

How can you expect others to take out time, when you yourself wants to take photos and share them


#3

Ok sorry ! I thought it would be more readable with a picture of my code.