Find for every name in array some user data out of another collection in Meteor

Hi Guys I am trying to get for every name in the array “eingeladene” the email adress the “Vorname” and the “Nachname” I have a for loop to go over again and again but my find is outputting “null” ;( so my find is not working correctly I have two collections one is named “Events” where the array is inside and in the collection “Benutzer” is the User Data i want to get.

In the array the “Vorname” is inserted so I am searching for the user with this name (“Vorname”) and than get the email + the “Nachname”

for (var i in eingeladene) {

    var email = Benutzer.findOne({"Vorname": eingeladene[i]}, {fields: {email: 1}});
    var Vorname = Benutzer.findOne({"Vorname": eingeladene[i]}, {fields: {Vorname: 1}});
    var Nachname = Benutzer.findOne({"Vorname": eingeladene[i]}, {fields: {Nachname: 1}});

    if (! email) {

    var emailData = {
        Name: Name,
        Beschreibung: Beschreibung,
        erstelltAm: new Date(),
        Datum: Datum,
        Eingeladen: eingeladene,
        Autor: Autor,
        Einladender: Einladender

        to: "email",
        from: "",
        subject: "Einladung",
        html: SSR.render('EinladungsEmail', emailData),


Thank you for every help and yes I already red the documentation By the way @iiro helped me to get so far

Update: I tried with the same code and to check the generated data I inserted the data in a different collection and I was wrong it is not “null” i now get this:

  "_id": "HDF3XnvKzovnNdEiW",

  "Email": {
    "_id": "Gkddi6KhYf6BmF3jv",
    "email": ""
  "Vorname": {
    "_id": "Gkddi6KhYf6BmF3jv",
    "Vorname": "exampleVorname"
  "Nachname": {
    "_id": "Gkddi6KhYf6BmF3jv",
    "Nachname": "exampleNachname"

The Problem with this is that for every part the id is inserted with the data

My goal would be this

"Email": ""

Hope you can help me now 😉


One thing I’m noticing is wrong is your syntax for findOne.

You don’t specify ‘fields’ in the object.

If you want just email:

Benutzer.findOne({Vorname: eingeladene[i]}, {email: 1});

Edit: Sorry just realized this isn’t a very efficient way of doing what you’re trying to do and you have some syntax issues.

A better solution with the same outcome:

var obj = Benutzer.findOne({'vorname': eingeladene[i]}, {});

var emailData = {
    beschreibung: obj.beschreibung,
    erstelltAm: new Date(),
    datum: obj.datum,
    eingeladen: obj.eingeladene,
    autor: obj.autor,
    einladender: obj.einladender

    from: "",

Making a different MongoDB is insanely inefficient when the first call will return all of the values you need.

Also variable names should be camelCased. It will help tremendously with readability. Maybe check out if you’re starting out.

I would highly recommend going through this tutorial as well, and actually code it out!