September 2017
Intermediate to advanced
450 pages
11h 24m
English
With our URL parameters passed through to Mongoose, we can make a variety of queries, including pagination pages and sizes, and finding posts by title:
http://localhost:3000/api/posts?page=3http://localhost:3000/api/posts?size=10&page=1http://localhost:3000/api/posts?title=foobar
Even more impressive, for published dates, we can actually send an entire date range query in the JSON format as a URLEncoded query parameter, and it will return to us only the posts with publish dates between these two ISO dates. For this date range filter to work, the dates must already be formatted in ISO 8601 standard to be successfully parsed by MongoDB:
http://localhost:3000/api/posts?published={"$gte": "2017-05-11T00:08:38.317Z", "$lt": "2017-06-08T11:57:14.963Z"} ...
Read now
Unlock full access