Hi. I'd like to do a "stats" association with Sequel, but I find myself a bit lost. I'm pretty sure there's a way to do that since association seem so powerful, but I'm kinda overwhelmed by the number of options and which one to use exactly.
Basically, I have two models: Project and Ticket. Each Project has Tickets, and each Ticket has hours (the number of hours spent working on it). I'd like to be able to load each Project with its total number of hours. Something like: select sum(hours) as hours from tickets group by project_id; I'd like to make that an association so that I can eagerly load it. I used datamapper before and it handles the (n+1) query problem automatically. I'm not exactly sure how to do that in Sequel so that I get the stats for all my project without launching N queries. Any idea? --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "sequel-talk" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/sequel-talk?hl=en -~----------~----~----~----~------~----~------~--~---
