Hi Patrick
Try this
Backendless.enablePromises();
function findAllPlaceHits() {
var dataStore = Backendless.Data.of('Place_Hits');
var dataQuery = new Backendless.DataQuery();
dataQuery.options = {
pageSize:100
};
var placeHits = [];
return new Promise((resolve, reject) => {
const handleResult = result => {
placeHits = placeHits.concat(result.data);
if (result.nextPage) {
result.nextPage().then(handleResult, reject);
} else {
//we reached the last page - it's time to resolve the promise
resolve(placeHits);
}
}
dataStore.find(placeHitDataQuery).then(handleResult, reject)
})
}
//custom business logic example
Backendless.ServerCode.customEvent('myCustomEvent', function() {
return findAllPlaceHits(restorants => {
//do whatever you need with restorants and return wanted result to the caller
})
})