I am trying to get the last record for a particular user id. For example.if user_id 2 has 10 records I need the 10th record.
I have tried for static user_id
Help me to change in dynamic
db.product_logs.find({"user_id" :"862"}).sort({"_id":-1}).limit(1)