title: Error occurs while changeStream watch() my mongodb database using nodeJs
body: <p>error : &quot;Collection method watch is synchronous&quot;.</p>
  <p>I have a database whatsAppdb in mongo atlas and now want to make my mongodb realtime so for that I uses changestream in mongodb collections as shown in the code but while doing that an error occurs &quot;collection method watch is synchronous&quot; as shown in the image.</p>
  <p>In console log &quot;Db is connected&quot; is printed if I don't write the db.collection(&quot;Contact&quot;) statement but app crashes as soon as  add this statement.</p>
  <p>/************************************/</p>
  <pre><code>    [    
  const db =mongoose.connection;
  db.once(&quot;open&quot;,function(){
      console.log(&quot;Db is connected&quot;);
  });
  
  const msgCollection = db.collection(&quot;Contact&quot;);
  const changeStream = msgCollection.watch();
  
  changeStream.on(&quot;change&quot;,function(change){
      console.log(change);
  });
  
  const contactsSchema = {
      id:Number,
      name : String,
      message:String,
      time:String
  
  };
  
  const Contact = mongoose.model(&quot;Contact&quot;, contactsSchema);
  
  app.get(&quot;/message&quot;,function(req,res){
      Contact.find(function(err,findContact){
          if(!err){
              res.send(findContact);
          }else{
              res.send(err);
          }
      });
  });
  
  app.post(&quot;/&quot;,function(req,res){
      Contact.create(req.body,function(err,data){
          if(!err){
              res.send(data);
          }else{
              res.send(&quot;Try Agian.&quot;);
          }
      });
  });
  
  
  
  app.listen(8000,function(err){
      if(!err){
          console.log(&quot;server started at port 8000&quot;);
      }else{
          console.log(err);
      }
  });]
  </code></pre>
  <p><a href="https://i.stack.imgur.com/fCuXt.png" rel="nofollow noreferrer">error screenshot</a></p>