Vulcan/client/lib/query.js
Tom Coleman 218f76347b Refactored the subscriptions to be all separate.
Probably still a bit of work to do to get things up to scratch, but looking good.
2012-10-18 13:07:10 +11:00

21 lines
No EOL
552 B
JavaScript

// Work around the lack of limit/offset in clientside queries.
//
// We fetch all the clients from the cursor, pick out the right ones,
// and decorate them with a special property that tells us the order they should
// appear in.
//
// This is a bit of a hack, and should probably be supported in core (somehow!)
var limitDocuments = function(cursor, limit) {
var i = 0;
var documents = [];
cursor.forEach(function(doc) {
if (i < limit) {
doc._rank = i;
documents.push(doc);
}
i += 1;
});
return documents;
}