I have two fields in database start_date and end_date. How to find if date which i am passing is in between these two dates.
Model
class Schedule
include Mongoid::Document
field :start_date, type: Date
field :end_date, type: Date
end
Simple activerecord query would be
Schedule.where(["start_date <= ? AND end_date >= ?", params[:date], params[:date] ])
Date is saved in database in following format
{
"_id" : ObjectId("559d182f6368611dbf000000"),
"start_date" : ISODate("2015-06-10T00:00:00.000Z"),
"end_date" : ISODate("2015-07-10T00:00:00.000Z")
}
and my parameter contain date like "2015-06-10"
What will be the query while using MongoDB database with Mongoid?