Here is the example of how you can do Pagination or Paging in MongoDB using Scala.
1. pageNumber : Page No. like 1st Page , 2nd Page and so on.
2. messagesPerPage : No of messages to be displayed on each page.
3. Here the find method we’ve used is of SalatDAO. You can use your own find method.