Skip to content

Instantly share code, notes, and snippets.

@MaerF0x0
Created October 31, 2013 00:22
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save MaerF0x0/7242600 to your computer and use it in GitHub Desktop.
Save MaerF0x0/7242600 to your computer and use it in GitHub Desktop.
Meteor publish and approximate SQL
Meteor.publish(
'scores',
function() {
return Scores.find(
{score:{$gt:100}},
{
fields: {user:1,score:1},
sort:{score:-1},
limit:10,
skip:pageNumber*pageSize
}
);
}
);
// SELECT user, score FROM scores WHERE score > 100 SORT BY SCORE DESC OFFSET X LIMIT 10
@TimeBandit
Copy link

you could also show where pageNumber & pageSize get passed in 👍

@jakobrosenberg
Copy link

Meteor.publish(
'scores',
function(pageNumber, pageSize) {
...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment