Is there something fundamentally wrong with this .find function? (Mongoose)

42
April 23, 2019, at 00:50 AM
const cleanMongo = (name) => {
        Item.find({ name: name }, (foundItem) => {
            console.log('found item equals', foundItem)
        });

For some reason, the .log is always says the search returns with null, when it should be returning with a matching document queried successfully only moments before.

Answer 1

First param is error on find's callback, so it should be

Item.find({ name: name }, (error, foundItem) => {
READ ALSO
Any suggestion to make my javascript + html code smaller

Any suggestion to make my javascript + html code smaller

Hello I have the code below that is for all country in the world (code become too big so I just copy a little of it)

27
how i sending an auth error from node js to my html client page?

how i sending an auth error from node js to my html client page?

Im new to node js and now im rewriting my website , I scripting the log in page , my issue is to send back to the client page the error message

49
Reload perticular textbox/select option using javaScript

Reload perticular textbox/select option using javaScript

I want to refresh/reload a particular textbox/ Select option using javaScriptJust like when the page loads for the first time

44
How to avoid triggering of repeated pubnub notification via JS on webpage return

How to avoid triggering of repeated pubnub notification via JS on webpage return

I have a problem with JS bootstrap notify event on using with pubnub

46