When performing CRUD operations through your Realm application, the maximum number of documents that can be returned is 50,000. See service limitations for more information.

In instances where your application returns more than 50,000 documents, we recommend paginating your query through an aggregation pipeline and using the $skip and $limit aggregation pipeline stages.

Here is an example on how you can use pagination logic in a Realm function:

exports = function(skipNumber, limitNumber) { 
// e.g. You can call the function(50000,10000) so that only the 50,001th to 60,000th documents will be retrieved }
const mongodb = context.services.get('<mongodb service name>');
const someCollection = mongodb.db('<some_db>').collection('<some_coll>');
const pipeline = [
{ "$skip" : skipNumber },
{ "$limit": limitNumber }
];
return someCollection.aggregate(pipeline).toArray()
}

Did this answer your question?