What does mongoose return when a find query is empty?

Viewed 14607

I'm setting up a function that searches for a user based on an id and if no user is found, it creates a new one. I have no users yet so the query never returns a user. However, I'm unable to successfully check for this case. What exactly is returned when a find query is empty?

 User.find(id,(error,user)=>{
        if(error){
          console.log(error);
        }else{
          if(user == [] || user == null || user == undefined || user == {} || user == '[]'){
            User.addUser({"fbID":id,"lastMessage":"[]"},(error,response)=>{
              if(error){
                console.log(error);
              }else{
                console.log(response);
              }
            });
          }else{
            console.log("User exists.");
          }
        }
      });
2 Answers
Related