I want to list out all the data records from Users table without using pagination. I’m using REST API.
Is there any separate API or I need to send any special parameter?
I want to list out all the data records from Users table without using pagination. I’m using REST API.
Is there any separate API or I need to send any special parameter?
Hello Ganesh
You can’t do that regarding to performance purposes. You should use pagination anyway, and you can see total objects when doing GET request to a table
Regards Anton
Also I can propose to you another way, via Business Logic
You need to add a new Custom API Service, how to do that and deploy you can find here https://backendless.com/documentation/business-logic/js/bl_overview.htm
And then you can load all records by only one requests
Example code:
'use strict';
const MAX_OBJECTS_PER_PAGE = 100;
const loadAllRecords = (className) => {
const classStorage = Backendless.Persistence.of(className);
return loadPortion(classStorage, 0, { data: [] })
};
const loadPortion = (classStorage, offset, prevResult) => {
const query = { options: { pageSize: MAX_OBJECTS_PER_PAGE, offset } };
return classStorage.find(query)
.then(portion => Object.assign(portion, { data: prevResult.data.concat(portion.data) }))
.then(result => {
if (result.data.length < result.totalObjects - MAX_OBJECTS_PER_PAGE) {
return loadPortion(classStorage, offset + MAX_OBJECTS_PER_PAGE, result);
}
return result
});
};
class CloudServices {
/**
* @returns {Promise.<Object>}
*/
getAllTableNameData() {
return loadAllRecords('TableName');
}
}
Backendless.enablePromises();
Backendless.ServerCode.addService(CloudServices);
Regards, Vlad
Thank you! It works for me.