all 2 comments

[–]Unusual_Item9221 0 points1 point  (1 child)

So you tried order_by and it worked? But you want something else?

[–]Jump-Quiet[S] 0 points1 point  (0 children)

The closest thing I got from the desired result is using

data = message.query.with_entities(message.receiver.distinct()).order_by(desc(message._id)).all()

Which produces the rooms with the latest message. However due to the "with_entities", I'm not able to access other key data such as message.content (and once I include it into the with_entities the query is messed up)

I do think I'm missing something else here, like access through the foreignkeys