View last N documents using MongoDB Compass View last N documents using MongoDB Compass mongodb mongodb

View last N documents using MongoDB Compass


MongoDB Compass 1.6.1(Stable)

For date comparison you need to use $date operator with a string that represents a date in ISO-8601 date format.

{"date": {"$gte": {"$date": "2017-03-13T09:51:26.317Z"}}}

In my case the values of date field in Compass and mongo shell are different. So firstly I query the documents in the shell and then copy the "2017-03-13T09:51:26.317Z" from the result to the Compass filter line. In mongo shell it look like:

{    ...    "date" : ISODate("2017-03-13T09:51:26.317Z"),     ...}

MongoDB Compass 1.7.0-beta.0 (Beta)

This version have an advanced query bar that lets you input not just the filter (as before), but also project, sort, skip and limitenter image description here


(@Oleksandr I learned from your effective answer; thank you.)

I've also been shown that the Compass Schema tab allows one to drag a date range on the _id field to apply a filter query for that range. That range can be successively narrowed as desired.

enter image description here


Skip is descibed herehttps://docs.mongodb.com/compass/current/query/skip/

  1. In the Query Bar, click Options.
  2. Enter an integer representing the number of documents to skip into the Skip field
  3. Click Find to run the query and view the updated results.

enter image description here