Finding users by a 'profile' field

This has stumped me, so I thought I’d see if it’s just my tired morning brain! I need to return users that are part of the organisation (then using forEach on them).

The orgId is definitely being called ok. Organisations are being displayed successfully in handlebars with profile.organisation.

Returned a count of orgUsers, and it’s coming back zero each time, even though there are definitely users with that orgId logged as their organisation.

Any ideas?

 var orgUsers = Meteor.users.find({profile: {organisation: orgId}});
1 Like

I think you should try the following code (you have to include the quotes for “profile.organisation”):

var orgUsers = Meteor.users.find({"profile.organisation": orgId});

Seee this section in the MongoDB docs for details


Beautiful. That worked a treat. Thanks @NickTheTurtle!

I often forget to check the MongoDB Docs…