In my mongoDB database, the documents have the following structure:
{username:String, paymentYear:Int, paymentMonth:Int}
I am trying to retrieve the latest document for a specific username, which would be the one with the date closest to the current Date.now() value. What would be the most effective approach for achieving this? Is there a specific mongoDB query I can utilize, or should I develop custom code for this task?
Appreciate any assistance. Thank you.