Node.js: How do range query in mongoose?
-
In mongodb javascript, i can use find({'datetime': {'$gt': '2011-04-01', '$lt': '2011-04-09'}}) to do range query, but can i do it in mongoose's find? Thanks
-
Answer:
I have been helped mongoose to fix this problem, so the latest mongoose supports it.
Shawn Yang at Quora Visit the source
Other answers
First, in the Schema, you need to define the type of the date field to be: {date: { type: Date, default: Date.now }} then when u query for the date range: Model.find({"date": {'$gte': new Date('3/1/2014'), '$lt': new Date('3/16/2014')}}, callback);
Razmig Youssef
Related Q & A:
- What can Node.js do that ASP.NET cannot?Best solution by Stack Overflow
- How can I install node.js module using phantom, instead of npm?Best solution by Stack Overflow
- how to browserify a node-js module?Best solution by Stack Overflow
- How do you install a specific version of Node.js?Best solution by Ask Ubuntu
- How to delete a line from a .txt file in node.js?Best solution by c-sharpcorner.com
Just Added Q & A:
- How many active mobile subscribers are there in China?Best solution by Quora
- How to find the right vacation?Best solution by bookit.com
- How To Make Your Own Primer?Best solution by thekrazycouponlady.com
- How do you get the domain & range?Best solution by ChaCha
- How do you open pop up blockers?Best solution by Yahoo! Answers
For every problem there is a solution! Proved by Solucija.
-
Got an issue and looking for advice?
-
Ask Solucija to search every corner of the Web for help.
-
Get workable solutions and helpful tips in a moment.
Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.