Given this collection:
db.Users.insertMany([
{ NameLast: "Smith", NameFirst: "John" },
{ NameLast: "Johnson", NameFirst: "Mary" }
]);
This query displays a result:
db.Users.find( { NameLast: "Smith" }, { NameLast: 1, NameFirst: 1, _id: 0 })
but this one inside of a JavaScript forEach loop does not:
[ 1 ].forEach((name) =>
db.Users.find( { NameLast: "Smith" }, { NameLast: 1, NameFirst: 1, _id: 0 }));
Is the output supressed? Redirected? How do I get the query results? Ultimately, the array will provide a list of names to search for.