Hi,
I have a use case where I currently keep 3 lists to store users on. Each of these lists stores users in different states. As their state changes I move them between the lists using rpoplpush. The problem I have encountered now is that I would like to be able to query the users based on other attibutes, thus using find methods on the list are slow and probably not the best solution. See my skimmed down models below
Eg:
class Campaign < Ohm:Model
list :active, :User
list :busy, :User
list :offline, :User
end
class User < Ohm:Model
reference :campaign, :Campaign
attribute :name
attribute :state
attribute :email
index :email
end
Can this be reformatted using collections rather so I can perform queries like: campaign.active.find(:email => '
f...@bar.com'), and also move the user between the 'lists'/collections by changing the :state attribute
eg:
class Campaign < Ohm:Model
collection :active, :User, lambda { |u| u.state == 'active' }
collection :busy, :User, lambda { |u| u.state == 'busy' }
collection :offline, :User, lambda { |u| u.state == 'offline' }
end
class User < Ohm:Model
reference :campaign, :Campaign
attribute :name
attribute :state
attribute :email
index :email
end
Now by changing the state attribute it will move the user between the collections without the need for rpoplpush
Any suggestions?
Thanks