code: def query_closest(self, query_item):
          
  
          if not isinstance(query_item, dict):
              raise TypeError("The query query_item isn't a dictionary")
          
          _type = query_item.get("type")
          _timestamp = query_item.get("timestamp")
  
          if _type is None:
              raise AttributeError("Please make sure to add a type to the query_item dict")
  
          if _timestamp is None:
              raise AttributeError("Timestamp doesn't exist. It's necessary to provide closest query")
          
          query_less = deepcopy(query_item)
          query_more = deepcopy(query_item)
          
          query_less["timestamp"] = {"$lte": _timestamp}
          query_more["timestamp"] = {"$gt": _timestamp}
          closestBelow = self._collection.find(query_less).sort(
              "timestamp", pymongo.DESCENDING).limit(1)
          closestAbove = self._collection.find(query_more).sort("timestamp", pymongo.ASCENDING).limit(1)
          
          combined = list(closestAbove) + list(closestBelow)
          for x in combined:
              del x['_id']
          
          # abs()
          if len(combined) >= 2: 
              if abs(combined[0]["timestamp"] - _timestamp) > abs(combined[1]["timestamp"] - _timestamp):
                  return combined[1]
              else:
                  return combined[0]
          elif combined == 1:
              return combined[0]
          else:
              return None
docs: closest = store.query_closest({"type": "...", "item_1": "...", "timestamp": "..."}) # returns a list of the closest items to a given thing