title: MongoDB Change Stream
body: <p>I try to code a MongoDB change stream. But if I do some changes, my code doesn't detect the changes. If the code detects the changes I have to get the operation type - according to my understanding. Moreover, how can I insert the changes in the other database? Is it so &quot;easy&quot;, that I code a new database connection and update/insert/delete the collection/database?</p>
  <p><strong>What did I Code?</strong>
  `</p>
  <pre><code>lang-cs
              string mongo_db_client = &quot;mongodb://localhost:27017&quot;;
              string m_database = &quot;myDataBase&quot;;
              string m_collection =&quot;myCollection&quot;;
            
              MongoClient dbClient = new MongoClient(mongo_db_client);
  
              var database = dbClient.GetDatabase(m_database);
              
              var collection = database.GetCollection&lt;BsonDocument&gt;(m_collection);
              var cursor = collection.Watch();
              var the_operation_type = null;
  
              if(cursor != null)
              {                   
                  using(cursor)
                  {
                      var curr =  cursor.Current;
                  
                      if (curr != null)
                      {
                          foreach (var change in curr)
                          {
                              try
                              {
                                  the_operation_type= change.OperationType;
                              }
                              catch(NullReferenceException e)
                              {
                                  Log(e.ToString());
                              }
                          }
                      }
                  }
              }
  </code></pre>
  <p>`</p>