Print out all object values from an Array Inside of a Field on MongoDB (javascript)

Viewed 31

I have a database that has different fields of data inside a document and I want to print out one of the objects from the array. I am only able to print out values that have values attached and not Arrays.

I am unable to add photos as I am new but this is what I am working with: Database photo

Code:

 async function listEmail(client) {
    const emailListing = await client
        .db("x")
        .collection("y")
        .find({})
        .forEach(function (i) { 
            console.log(`id = ${i.firstName}, email = ${i.authentications.username}`);
        });
}

I would like to just print out their first name and email (username)

This is my Output.

0 Answers
Related