Hi
I have following db structure:
File, User, FileRevision (has foreign key to File, and many-2-many connection through intermediate table to User).
I want to fetch all FileRevision-s that:
- are newest/freshest in their corresponding File-s,
- have many-2-many link to User that performs search (permission checking).
I found out that I can do (1) by executing something like:
SELECT created_on, file_id FROM FileRevision
WHERE created_on = (SELECT MAX(created_on) FROM FileRevision
WHERE filed_id = file_id)
but I have no clue how to simultaneously perform also m2m permission check