javascript - Sorting Azure Mobile Services API -


i want return sorted table rest service, getting last record, doing wrong here? ideally want limit records returned, example top 100 ? thank you

rest: https://restname.azure-mobile.net/api/test

exports.get = function(request, response) {     var collectionofvotes = request.service.tables.gettable('country'); collectionofvotes.orderbydescending('countryname') .read({ success: function(results) {      results.foreach(function(r) {             response.send(r);             //console.log(r);         }); }}); 

};

you're calling method response.send every record returned query. since 1 request sent, 1 of responses returned. if want send records back, should send results passed success callback.

also, can limit number of records returned using take method in table / query object, shown below.

exports.get = function(request, response) {         var collectionofvotes = request.service.tables.gettable('country');     collectionofvotes.orderbydescending('countryname').take(100)         .read({             success: function(results) {                 console.log('results: ', results);                 response.send(200, results);             }         }); }; 

Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -