Skip to content

Between Queries for Timestamps #37

@stevievines

Description

@stevievines

I was wondering whether it is possible to do "between" queries with the Ohm::Timestamps module.

For example, is it possible to do a query like this ActiveRecord query:

 User.where(created_at: @date_start..@date_end)

Right now, I am just grabbing them all, sorting by created_at and iterating over the results using a select:

AnonymousVisitor.find(store_id: store_id).sort_by(:created_at).select do |visitor|
  visitor.created_at >= date_start && visitor.created_at < date_end
end

But I imagine this will be an expensive operation. Is there a good way to do this?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions