Sorting the collection locally
dpatte opened this issue · 0 comments
My business requirements specifies that my mongo docs should be displayed sorted and paged in a table, where their sort order ignores their case. Unfortunately, sorting while ignoring case, is not supported using the current Mongo publication interface.
So currently, my publication must request the complete collection, unsorted, and I must sort the docs locally, then determine which docs I can display for the page.
I am doing that. I copy the whole unsorted minimongo collection into a reactive array (using observe), then sort, then display the correct portion of that instead, and it works, but:
- its unfortunately that I am required to publish the complete collection in order to determine which subset of docs to display. I only display 20 docs per page.
- its also unfortunate that I lose the nice blaze feature that a single doc update only causes the matching displayed doc to be refreshed. Currently, because I am sorting using a reactive array, any displayed doc change causes all my displayed docs to be redisplayed.
Am I missing something? Is there any way I can hook into mongo/minimongo to specify my more specific publication request, and is there any way I can write something that supports blaze's singledoc display optimization, but when using arrays of docs instead of a collection?
As my number of docs in my collection increases, this is becoming more and more critical.
Any suggestions would be handy. THX