Meteor/MongoDB limiting the result -
i trying find documents , publish @ 5 results.
following this section of mongodb doc, trying this:
meteor.publish('teams', function () { return teams.find().limit(5); }); yet, in server console, exception:
exception sub teams id pm6jkl8sv3fsdstfm typeerror: object [object object] has no method 'limit' the following works fine:
meteor.publish('teams', function () { return teams.find({}, {limit:5}); }); why second way work, rather first? , can find documentation it?
meteor's collection api different of mongo api. find takes 2 parameters: selector object, , options object. options allows specify such things sort, skip, limit , fields, in addition meteor-specific reactive , transform.
Comments
Post a Comment