I have a large mongodb collection where each document represents a simple log message that occurs at at set time interval (say 1 minute). Whenever I do a Find
using Mongoose, I get the entire contents of the DB in the order which they were added. I am looking for a query where I can get the last 10 added records without doing a sort on a timestamp. Below is a sample of my of my documents:
[ { _id: 58bd2dcd51d1169260ccbdac,
contentID: 1,
clicks: 50,
views: 61 },
{ _id: 58bd43d40fda0d25b0c6724e,
'contentID: ': 1,
clicks: 45,
views: 72 },
{ _id: 58bd54ae2d67e820143eddda,
'contentID: ': 1,
clicks: 25,
views: 32 }]