Less-than queries in a Lotus Model Repository

284 Views Asked by At

Is it possible to perform the following query in a Lotus::Model Repository?

def active
  query.where("publish_at >= #{Date.today}")
end

In Sequel, which Lotus::Model uses, you can do the above or you can pass it a block like so

where{publish_at >= Date.today}

This does not seem possible in Lotus as the conditions internal variable is a Set that requires a key and a value. I would love to know if anyone else has gotten this to work or a work around.

2

There are 2 best solutions below

0
On BEST ANSWER

The query interface doesn't accept yet other values than the hash with a single key/value pair (eg. where(name: 'Lotus'). I'm planning to empower it soon.

UPDATE: the lambda style query is now implemented in master.

1
On

This should work

def self.created_after(date)
  query do
    where("created_at > #{date}")
  end
end