Having the strangest problem. I can't display the email
property of an object. I'm using Mongoose/Express/Jade. I'm doing a:
User.find({ _id : { $in : req.project.subscribers } } , function (err, subs){...
Which works just fine and returns a list of my subscribers in the subs var that looks like so:
{ _id: 4f34832b9398bec847000002,
email: 'steve@example.com',
first_name: 'Steve',
last_name: 'McQueen',
status: 'active',
username: 'steve',
updated_at: Fri, 10 Feb 2012 02:38:35 GMT,
created_at: Fri, 10 Feb 2012 02:38:35 GMT,
role: 'subscriber' },
{ _id: 4f3484a9eceb82b548000002,
email: 'paul@example.com',
first_name: 'Paul',
last_name: 'Stanley',
status: 'active',
username: 'paul',
updated_at: Mon, 02 Apr 2012 15:09:56 GMT,
created_at: Mon, 02 Apr 2012 15:09:56 GMT,
role: 'subscriber' }
I then pass that to my jade view in a var called subscribers.
All good to this point, the problem arises when I want to display the email
property of each subscriber when I iterate over subscribers
in my jade template. It's only a problem with email
for some reason! It doesn't show anything for email
, just blank.
ul
each sub in subscribers
li= sub.email
It works fine if I substitute ANY of the other properties in place of email
. So the following displays perfectly fine:
ul
each sub in subscribers
li= sub.username
Please let me know if I can supply any more detail.
EDIT for Declan:
Doing the following:
ul
each val, key in subscribers
li #{key}: #{val}
Yields:
0: { _id: 4f34832b9398bec847000002, email: 'foo', first_name: 'Steve', last_name:
'McQueen', status: 'active', username: 'steve', updated_at: Fri, 10 Feb 2012 02:38:35 GMT,
created_at: Fri, 10 Feb 2012 02:38:35 GMT, role: 'subscriber' }
1: { _id: 4f3484a9eceb82b548000002, email: 'foo', first_name: 'Paul', last_name: 'Stanley',
status: 'active', username: 'paul', updated_at: Mon, 02 Apr 2012 16:05:51 GMT, created_at:
Mon, 02 Apr 2012 16:05:51 GMT, role: 'subscriber' }