On Tue, Jun 2, 2009 at 7:51 PM, Timur Abishev <[email protected]> wrote:
>
> Hi.
> I have 2 tables: items and sessions
> Item has many sessions and session has many items.
> I.e.
> class Item
>  include DataMapper::Resource
>  has n, :sessions, :through => Resource
> end
> class Session
>  include DataMapper::Resource
>  has n, :items, :through => Resource
> end
>
> How I may select all items without some session ?

Using an intermediate model for n:m is almost always a good thing:
https://gist.github.com/0b9fac8f886b6f323cf2

To select all items in one scoop you can use :conditions => ["...",
arg1, arg2] syntax, or if there aren't that many
items, just map intermediate models list to items list

Raw SQL queries is area when DataObjects adapter and Query syntax
needs some improvements in DM, it is true.
-- 
MK

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"DataMapper" 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/datamapper?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to