class_docstr: This handler handles connection and execution of the MongoDB statements.
class_docstr_tok: ["This","handler","handles","connection","and","execution","of","the","MongoDB","statements","."]
code: def subscribe(
      self, stop_event, callback, table_name, columns=None, **kwargs
  ):
      con = self.connect()
      cur = con[self.database][table_name].watch()
      while True:
          if stop_event.is_set():
              cur.close()
              return
  
          res = cur.try_next()
          if res is None:
              time.sleep(self._SUBSCRIBE_SLEEP_INTERVAL)
              continue
          _id = res["documentKey"]["_id"]
          if res["operationType"] == "insert":
              if columns is not None:
                  updated_columns = set(res["fullDocument"].keys())
                  if not set(columns) & set(updated_columns):
                      # do nothing
                      continue
  
              callback(row=res["fullDocument"], key={"_id": _id})
          if res["operationType"] == "update":
              if columns is not None:
                  updated_columns = set(
                      res["updateDescription"]["updatedFields"].keys()
                  )
                  if not set(columns) & set(updated_columns):
                      # do nothing
                      continue
  
              # get all document
              full_doc = con[self.database][table_name].find_one(
                  res["documentKey"]
              )
              callback(row=full_doc, key={"_id": _id})
  
imports: import re
  import time
  from collections import OrderedDict
  from bson import ObjectId
  import certifi
  import pandas
  import pymongo
  from pymongo import MongoClient
  from mindsdb_sql.parser.ast.base import ASTNode
  from mindsdb.utilities import log
  from mindsdb.integrations.libs.base import DatabaseHandler
  from mindsdb.integrations.libs.const import HANDLER_CONNECTION_ARG_TYPE
  from mindsdb.integrations.libs.response import HandlerStatusResponse, HandlerResponse, RESPONSE_TYPE
  from .utils.mongodb_render import MongodbRender
  from mindsdb.api.mongo.utilities.mongodb_query import MongoQuery
  from mindsdb.api.mongo.utilities.mongodb_parser import MongodbParser
label_desc: Use image node_id 4 for calling the MongoDBHandler obj's underlying member method code with example usage: obj.subscribe(stop_event, callback, table_name, columns) without return types