class_docstr: Datasource for reading from and writing to MongoDB.
class_docstr_tok: ["Datasource","for","reading","from","and","writing","to","MongoDB","."]
code: def __init__(
      self,
      uri: str,
      database: str,
      collection: str,
      pipeline: Optional[List[Dict]] = None,
      schema: Optional["pymongoarrow.api.Schema"] = None,
      **mongo_args,
  ):
      self._uri = uri
      self._database = database
      self._collection = collection
      self._pipeline = pipeline
      self._schema = schema
      self._mongo_args = mongo_args
      # If pipeline is unspecified, read the entire collection.
      if not pipeline:
          self._pipeline = [{"$match": {"_id": {"$exists": "true"}}}]
      # Initialize Mongo client lazily later when creating read tasks.
      self._client = None
  
file_path: ray/python/ray/data/datasource/mongo_datasource.py
imports: import logging
  from typing import TYPE_CHECKING, Dict, List, Optional
  from ray.data.block import Block, BlockMetadata
  from ray.data.datasource.datasource import Datasource, ReadTask
  from ray.util.annotations import PublicAPI
label_desc: Use image node_id 1 to create a new MongoDatasource object from inherited base classes: Datasource with example: obj = MongoDatasource(uri, database, collection, pipeline, schema)