👩💻 Join our community of thousands of amazing developers!
Project: codever - File: personal-bookmarks.service.js Use the sort and limit methods. In the following example we receive the latest 30 (limit) created bookmarks (sort descending by createdAt date) : let getLastCreatedBookmarks = async (userId) => { const bookmarks = await Bookmark.find({userId: userId}) .sort({createdAt: -1}) // -1 for descending sort .limit(30); return bookmarks; }; Reference - https://docs.mongodb.com/manual/reference/method/cursor.sort/ Shared...