Lookups/calcultions based on has_many relationships
I will try to be very precise and concise, so apologies if this comes off rude-ish.
- The history table contains a long list of entires that a user enters the application. Imagine like a list of chat entries.
- The users can bookmark any number of those history entries
- when retrieving a list of entries (e.g., last 40 entries, or all entries in a paged manner) I would like to try and in one go retrieve both the entries and whether they were bookmarked by this particular user
A corresponding SQL query would be something like
I have it sort of figured out with relationships and calculations, but this seems to load more data than I would actually like.
Relevant parts only:
And the bookmarks:
Continued below
- The history table contains a long list of entires that a user enters the application. Imagine like a list of chat entries.
- The users can bookmark any number of those history entries
- when retrieving a list of entries (e.g., last 40 entries, or all entries in a paged manner) I would like to try and in one go retrieve both the entries and whether they were bookmarked by this particular user
A corresponding SQL query would be something like
I have it sort of figured out with relationships and calculations, but this seems to load more data than I would actually like.
Relevant parts only:
And the bookmarks:
Continued below
