Seems easy enough with this patch:
module Sequel::Model::ClassMethods
def exists?
select(1).first != nil
end
end
module Sequel::Postgres::DatasetMethods
def exists?
db.select(1).where(self.exists).first != nil
end
end
On Thursday, July 2, 2015 at 4:11:14 PM UTC-7, Elad Ossadon wrote:
>
> Feature request:
>
> Have exists? method for dataset:
>
> Article.where(slug: "hello").exists?
>
> will return true/false.
>
> Currently the syntax (unless I'm missing something) is quite cumbersome:
>
> DB.select(1).where(Article.where(slug: "hello").exists).first != nil
>
>
>
--
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 http://groups.google.com/group/sequel-talk.
For more options, visit https://groups.google.com/d/optout.