Özer Gül

MongoDB Get Specific Field From Collection in Meteor

2016 05 04 Javascript

Hello, today I wanted to get one field from my collection in meteor.

For this, I created template helper and added two parameters like this.

Template.registerHelper( 'getInfo', (id, field) => {
    return Users.findOne({ _id: id}).[field] 
});

Now I am getting specific information of user by specific id.

Usage in template:
[hmtl]{{getInfo userID “user_name”}}[/html]
or you can use like this:
[hmtl][/html]

Enjoy 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *

(c) Özer Gül, css framework w3.css