ioxiocom / firedantic

Database models for Firestore using Pydantic base models.
BSD 3-Clause "New" or "Revised" License
43 stars 13 forks source link

Support all query filters from Firestore #2

Closed fbjorn closed 3 years ago

fbjorn commented 3 years ago
    @classmethod
    def find(cls: Type[TModel], filter_: dict) -> List[TModel]:
        """Returns a list of models from the database based on a filter.
        :param filter_: The filter criteria.
        :return: List of found models.
        """
        coll = cls._get_col_ref()

        query = coll

        for key, value in filter_.items():
            query = query.where(key, "==", value)

Currently we assume that filters can only contain equality checks, cause we're composing query as .where(key, "==", value).

Need to support other filters like >= or in.

The list of supported operations can be found in firestore docs

lietu commented 3 years ago

Solved by #11