sorting - How to publish a limited number of records from a collection in Meteor? -


so i'm familiar collection.find({}, {limit: somenumber}). here's problem:

i have lots of records in collection have createdat field sorting. i'm displaying paginated list of them on client.

i'm publishing collection , sorting/limiting cursor on both server , client. however, happens because data doesn't sent in order, server doesn't send correct items. if have 600 records, want see first 30 initially, see 30 list items on screen, flicker , change until client receives 600 records, @ point can sort them correctly.

essentially, meteor seems ignore fact want cursor sorted on server-side.

what doing wrong? how can make server send first 30 records (they don't need sent in order, need be first 30 according sorting rule)

edit: solved it, problem in query, looked empty string in 1 of fields, , confused server.

you have sort on server:

collection.find({}, {sort: {createdat: -1}},limit: somenumber); 

Comments