I try to implement a very simple backend using deno and it's third party module for mongo to access a MonogoDB.
However using the .find() function i am not able to correctly pass the results through my API.
Here is a generalized version of the function i try to write:
getElementbySearch: async (
{ searchKey, response } : {searchKey: ElementSchema, response: any}
) => {
const results = await elements.find(searchKey)
if (!results) {
response.status = 404;
response.body = {
success: false,
message: "No element found",
};
return;
}
response.status = 200;
response.body = {
success: true,
data: results,
};
}
The rest of the backend is working properly, e.g. i have successfully implemented a getAllElements API.
Trying different searchkeys on a mongoDB does also work just fine.