I think the following should work (although I'm not certain): User.all( :links => [User.relationships[:entries]], :conditions => ["entries.created_at <= ? OR entries.created_at >= ?",date1, date2] )
On Jan 4, 7:27 pm, deadwards <[email protected]> wrote: > Would it be possible to use this method to search by associations? > > Say I have a User that has many Entries. Could I search for all users > that have entries before a certain date OR after a certain date? > > In Rails/AR: > User.all(:includes => :entries, :conditions => ["entries.created_at > <= ? OR entries.created_at >= ?", 6.weeks.ago, 2.weeks.ago]) > > How would I accomplish this with DataMapper? > > On Jan 4, 3:48 am, Dirkjan Bussink <[email protected]> wrote: > > > > > On 4 Jan 2009, at 04:52, deadwards wrote: > > > > Ok, I'm very new to DataMapper (with Merb), and I have a stupid > > > question. How do I do an 'OR' select on a model. After all of my > > > searching, I can only find selects that only use 'AND' conditions. Is > > > it possible to do an 'OR' find? If so, how? > > > For now you have to use the :conditions option of a finder, but we are > > working on designing an API that allows for easy OR's. This is an > > example of how you could do it now: > > > User.all(:conditions => ["username = ? OR password = ?", username, > > password]) > > > -- > > Regards, > > > Dirkjan Bussink --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
