class_docstr: This handler handles connection and execution of the ChromaDB statements.
class_docstr_tok: ["This","handler","handles","connection","and","execution","of","the","ChromaDB","statements","."]
docstr: Translate a list of FilterCondition objects a dict that can be used by ChromaDB.
  E.g.,
  [
      FilterCondition(
          column="metadata.created_at",
          op=FilterOperator.LESS_THAN,
          value="2020-01-01",
      ),
      FilterCondition(
          column="metadata.created_at",
          op=FilterOperator.GREATER_THAN,
          value="2019-01-01",
      )
  ]
  -->
  {
      "$and": [
          {"created_at": {"$lt": "2020-01-01"}},
          {"created_at": {"$gt": "2019-01-01"}}
      ]
  }
docstr_tok: ["Translate","a","list","of","FilterCondition","objects","a","dict","that","can","be","used","by","ChromaDB",".","E.g.",",","[","FilterCondition","(","column=","''","metadata.created_at","''",",","op=FilterOperator.LESS_THAN",",","value=","''","2020-01-01","''",",",")",",","FilterCondition","(","column=","''","metadata.created_at","''",",","op=FilterOperator.GREATER_THAN",",","value=","''","2019-01-01","''",",",")","]","--",">","{","``","$","and","''",":","[","{","``","created_at","''",":","{","``","$","lt","''",":","``","2020-01-01","''","}","}",",","{","``","created_at","''",":","{","``","$","gt","''",":","``","2019-01-01","''","}","}","]","}"]
code: def _translate_metadata_condition(
      self, conditions: List[FilterCondition]
  ) -> Optional[dict]:
      """
      Translate a list of FilterCondition objects a dict that can be used by ChromaDB.
      E.g.,
      [
          FilterCondition(
              column="metadata.created_at",
              op=FilterOperator.LESS_THAN,
              value="2020-01-01",
          ),
          FilterCondition(
              column="metadata.created_at",
              op=FilterOperator.GREATER_THAN,
              value="2019-01-01",
          )
      ]
      -->
      {
          "$and": [
              {"created_at": {"$lt": "2020-01-01"}},
              {"created_at": {"$gt": "2019-01-01"}}
          ]
      }
      """
      # we ignore all non-metadata conditions
      if conditions is None:
          return None
      metadata_conditions = [
          condition
          for condition in conditions
          if condition.column.startswith(TableField.METADATA.value)
      ]
      if len(metadata_conditions) == 0:
          return None
  
      # we translate each metadata condition into a dict
      chroma_db_conditions = []
      for condition in metadata_conditions:
          metadata_key = condition.column.split(".")[-1]
          chroma_db_conditions.append(
              {
                  metadata_key: {
                      self._get_chromadb_operator(
                          condition.op
                      ): condition.value
                  }
              }
          )
  
      # we combine all metadata conditions into a single dict
      metadata_condition = (
          {"$and": chroma_db_conditions}
          if len(chroma_db_conditions) > 1
          else chroma_db_conditions[0]
      )
      return metadata_condition
  
imports: import sys
  from collections import OrderedDict
  from typing import List, Optional
  import pandas
  from mindsdb.integrations.handlers.chromadb_handler.settings import ChromaHandlerConfig
  from mindsdb.integrations.libs.const import HANDLER_CONNECTION_ARG_TYPE
  from mindsdb.integrations.libs.response import RESPONSE_TYPE
  from mindsdb.integrations.libs.response import HandlerResponse
  from mindsdb.integrations.libs.response import HandlerResponse
  from mindsdb.integrations.libs.response import HandlerStatusResponse
  from mindsdb.integrations.libs.vectordatabase_handler import FilterCondition, FilterOperator, TableField, VectorStoreHandler
  from mindsdb.interfaces.storage.model_fs import HandlerStorage
  from mindsdb.utilities import log
label_desc: Use image node_id 9 for calling the ChromaDBHandler obj's underlying member method code with example usage: obj._translate_metadata_condition(conditions) and returns: metadata_condition, None, None