On Mon, May 31, 2021 at 8:59 PM Adam Aiken <[email protected]> wrote:
> Hi, I am trying to have additional conditions on association.
>
> Say typically it looks like:
>
> class Post < Sequel::Model
> one_to_many: :comments, conditions: { time_deleted: nil }
> end
>
> However, I want to do the opposite like `time_deleted` is not nil.
> Does sequel support such operation for conditions?
>
Yes. In this case, you can use:
class Post < Sequel::Model
one_to_many: :comments, conditions: { time_deleted: Sequel::NOTNULL }
end
For generic negation, you can use Sequel.~:
class Post < Sequel::Model
one_to_many: :comments, conditions: Sequel.~({ time_deleted: nil })
end
Thanks,
Jeremy
--
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 view this discussion on the web visit
https://groups.google.com/d/msgid/sequel-talk/CADGZSSdOGghmJxOVb_hVHfxhJCrJtX4dax_EM-Bu-ZBjq2s%3DvQ%40mail.gmail.com.