mongodb - How do I list Meteor users and only show their first email address? -


i'm listing meteor users in template:

<template name="userlist">     <ul>     {{#each users}}         <li>             {{_id}}<br>             emails:                 {{#each emails}}                     {{address}},                 {{/each}}         </li>     {{/each}}     </ul> </template> 

here's helper:

template.userlist.helpers({     users : function() {         return meteor.users.find({});     } }); 

this works, since i'm not using usernames, want list first email address , not have handle {{#each}} in template. ideally, i'd have value users.primaryemail, changed helper this:

template.userlist.helpers({     users : function() {         var rawusers = meteor.users.find({});         var users = [];         _.each(rawusers, function(user) {             user.primaryemail = user.emails[0].address;             users.push(user);         })         return users;     } }); 

...and updated template code output {{primaryemail}}, doesn't seem return users @ now. missing?

figured out needed use .fetch() in order results array & make users.emails[0] work:

var rawusers = meteor.users.find({}).fetch(); 

Comments

Popular posts from this blog

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -