1

I have many users. Some may have the same 'top' (type of problem) and the timestamp will naturally be unique. I am trying to find users/documents with a specific top (i.e "top":1) but amongst those, I only want the one with the smallest/minimum timestamp.

db.collection.find( {'top':1} ).min("timestamp")

What am I doing wrong here? Thanks in advance!

enter image description here

Han
  • 407
  • 2
  • 5
  • 16
  • Does this answer your question? [How to find min value in mongodb](https://stackoverflow.com/questions/6360465/how-to-find-min-value-in-mongodb) – Anurag Srivastava Apr 17 '20 at 20:29

1 Answers1

0

.find(...).next() is the solution

Han
  • 407
  • 2
  • 5
  • 16