I have the following cookie cutter code, that just simply looks to select records with a specific field value (that I know exist in my database) with a MongoClient:
await client.connect()
const db = client.db("myDb");
const collection = db.collection("myCollection");
const result = await collection.find({
"fieldName": "myField"
},
{}
)
.toArray();
await client.close();
console.log(result);
I know that it works in the case when there is no query, as I successfully could get every data dumped in the result array before, however with the above query, it only writes an empty array to the console, and I could not, for the life of me, figure out why.
user28751094 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2