Supporting composite keys in SimpleRecord

6 views
Skip to first unread message

Travis Reeder

unread,
Jan 21, 2011, 12:18:31 AM1/21/11
to simple-record
Been thinking of adding some special support for composite keys so you can define them on your model and it will automatically create the key and allow you to query on them.

eg:

class MyModel < SimpleRecord::Base
    belongs_to :something
    has_dates :somedate

    composite_key :something, :somedate, ....

end

That would create a key based on those fields so you could query on it with something like:

:conditions=>["#{MyModel.ck_name(:something, :somedate)} > ?", MyModel.ck_val(some_id, 7.days.ago)]

That conditions part seems a little overcomplicated, but something like that anyways.

Thoughts?

Reply all
Reply to author
Forward
0 new messages