All Collections
Realm
The maximum number of returned documents in an App Services function
The maximum number of returned documents in an App Services function
Mary Gorman avatar
Written by Mary Gorman
Updated over a week ago

When performing CRUD operations through your App Services 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 of how you can use pagination logic in an App Services 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?