Turistforeningen / node-mongo-querystring

Query builder for accepting URL query parameters into your MongoDB queries. Safe and feature rich. Supports most of MongoDB's query operators such as $eq, $gt, $lt, $ne, $in, $nin, $exists, $regex, geospatial queries such as bbox and near, as well as your own custom query business logic!
MIT License
100 stars 31 forks source link

before, after, between should use date object instead of date string #67

Open kyv opened 7 years ago

kyv commented 7 years ago

In the mongodb shell I get no results if I try to pass a query such as the following: { endret: { $gte: "2014-01-01T00:00:00.000Z" } }. However, this does work for me: { endret: { $gte: new ISODate("2014-01-01T00:00:00.000Z") } }. This also works from javascript: { endret: { $gte: new Date("2014-01-01T00:00:00.000Z") } }.

Is this an error or am I missing something? maybe something changed in newer mongodb versions?

Starefossen commented 7 years ago

I think this was done this because we originally had a large database where the dates were formatted as strings and not date objects if I recall correctly.

If you would like to change the implementation I would like there to be an option to toggle between strings and dates, where stings would be default until next major version.