Skip to content Skip to sidebar Skip to footer

Limit Number Of Field Return From Mongodb In Meteor

I am have a collection that stores documents that contains user informations like Email, Phone Number, etc. I want to be able to return only 5 fields that exist in the document, fo

Solution 1:

The idea is to transfer your collection in another ( result ) array, and to retrieve this array in your handlebar template :

Users  = new Meteor.Collection("users"); 
LIMIT =4;

Template.userShow.users = function () {
    var users = Users.find().fetch();
    for (var i = 0; i < LIMIT; i++) {
        result[i] =  users[i];  
    }
    return result ;
};

Solution 2:


Post a Comment for "Limit Number Of Field Return From Mongodb In Meteor"