node.js - How to query firebase on the last (x,y)? -


i listing array based on votes (orderbychild('up')) , divide them pages (limittolast(10*formdata.page)). however, limittolast() takes 1 attribute rather two, example if page 10, have huge list of items...

ref.orderbychild('up').limittolast(10*formdata.page).once('value', function(snapshot) {   var data = [];   snapshot.foreach(function(child) {     data.unshift(child.val());   });   response.writehead(200, {'content-type': 'application/javascript'});   response.write(json.stringify(data));   response.end(); }, function (errorobject) {   console.log('database reading error: ' + errorobject.code);   response.writehead(500, {'content-type': 'text/html'});   response.write('database reading error: ' + errorobject.code);   response.end(); }); 

of course can use function similar one:

function reversedchildren(snapshot) {     var children = [];     snapshot.foreach(function (child) { children.unshift(child); });     return children; } 

but method seems require getting entire list first , use snapshot.foreach reverse list before turning them list. let's if list 4gb, means need load 4gb of data show 10 entries...


Comments

Popular posts from this blog

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

python Tkinter Capturing keyboard events save as one single string -

sql server - Why does Linq-to-SQL add unnecessary COUNT()? -