> def stuff_count
> values[:stuffs_count] || stuffs_dataset.count
> end
yessss thanks jeremy! that bit was pretty much wat i was looking for!
but i found a better solution...
> You're looking for a counter cache.
i'm not, but i do plan to use this sort of technique at some point...
in teh end, i just made another model:
class AccountStuffCount < Sequel::Model(Stuff.group_and_count(:account_id))
end
class Account < Sequel::Model
one_to_one :account_stuff_count
def stuff_count
account_stuff_count.count
end
end
it uses no magic, allows eager loading and is easily optimizable with
a count cache or materialized view!
ty anyway! <3
--
Igor
--
You received this message because you are subscribed to the Google Groups
"sequel-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.