I have mongoose schema which has a day attribute which is just
Math.floor((new Date()).getTime() / (24 * 3600 * 1000))
and I want to find the data for the last day entered so say today is 16085
then I want to find the last day entered. Or another way of saying this would be. What is the document with a day
attribute less then 16085
but greater then all other documents where day
is also less then 16085
.
or another way
What is the maximal element of the set of all documents with a day
attribute less then 16085
Other then iterating over all of my documents, how could I do this?