30

How to use skip() and limit() in meteor?

Post.find({"user_id":user_id}).skip(0).limit(5);

when I execute above line server says

Exception while invoking method 'Userpost' TypeError: Object [object Object] has no method 'skip'

Konrad Krakowiak
  • 12,285
  • 11
  • 58
  • 45
Ramesh Murugesan
  • 4,727
  • 7
  • 42
  • 67

2 Answers2

53

You should try putting the skip and limit options as an object parameter within the find() method as follows:

Post.find({"user_id":user_id}, {skip: 0, limit: 5});
chridam
  • 100,957
  • 23
  • 236
  • 235
6

Here is the doc about collection.find([selector], [options])

skip and limit are options of the find method

Leo
  • 629
  • 1
  • 9
  • 25