When I attempt to search for items in a collection using the console with db.DB_NAME.find({ x: y }, it works perfectly. However, when trying to do the same in the code, it doesn't seem to work.
It's worth mentioning that the findOne method works flawlessly within the code.
Code:
app.get("/api/customer/:cpf", async (req, res) => {
const properties = await Customer.consult(req);
console.log(properties);
res.status(200);
res.end();
});
static async consult(req) {
const conn = await client.connect();
const db = conn.db("website");
const cpf = req.params.cpf.toString();
console.log(cpf);
const properties = await db.collection("Property").find({
customerCpf: cpf,
});
return properties;
}
Instead of receiving the expected three objects, what I'm seeing in my console from these code snippets is a large and perplexing object, which is confusing for me as a novice.