pub(crate) fn convert_filter(filter: Filter, invert: bool) -> crate::Result<MongoFilter> {
    let filter_pair = match filter {
        Filter::And(filters) if invert => coerce_empty(false, "$or", filters, invert)?,
        Filter::And(filters) => coerce_empty(true, "$and", filters, invert)?,

        Filter::Or(filters) if invert => coerce_empty(true, "$and", filters, invert)?,
        Filter::Or(filters) => coerce_empty(false, "$or", filters, invert)?,

        Filter::Not(filters) if invert => coerce_empty(false, "$or", filters, !invert)?,
        Filter::Not(filters) => coerce_empty(true, "$and", filters, !invert)?,

        Filter::Scalar(sf) => scalar_filter(sf, invert, true)?,
        Filter::Empty => MongoFilter::Scalar(doc! {}),
        Filter::ScalarList(slf) => scalar_list_filter(slf, invert)?,
        Filter::OneRelationIsNull(filter) => one_is_null(filter, invert),
        Filter::Relation(rfilter) => relation_filter(rfilter, invert)?,
        // Filter::BoolFilter(b) => {} // Potentially not doable.
        Filter::Aggregation(filter) => aggregation_filter(filter, invert)?,
        _ => todo!("Incomplete filter implementation."),
    };

    Ok(filter_pair)
}
/// Builds a MongoDB query filter from a Prisma filter.
Builds a MongoDB query filter from a Prisma filter.
Builds a MongoDB query filter from a Prisma filter .
pub(crate) fn convert_filter(filter: Filter, invert: bool) -> crate::Result<MongoFilter> {
    let filter_pair = match filter {
        Filter::And(filters) if invert => coerce_empty(false, "$or", filters, invert)?,
        Filter::And(filters) => coerce_empty(true, "$and", filters, invert)?,
        Filter::Or(filters) if invert => coerce_empty(true, "$and", filters, invert)?,
        Filter::Or(filters) => coerce_empty(false, "$or", filters, invert)?,
        Filter::Not(filters) if invert => coerce_empty(false, "$or", filters, !invert)?,
        Filter::Not(filters) => coerce_empty(true, "$and", filters, !invert)?,
        Filter::Scalar(sf) => scalar_filter(sf, invert, true)?,
        Filter::Empty => MongoFilter::Scalar(doc! {}),
        Filter::ScalarList(slf) => scalar_list_filter(slf, invert)?,
        Filter::OneRelationIsNull(filter) => one_is_null(filter, invert),
        Filter::Relation(rfilter) => relation_filter(rfilter, invert)?,
        // Filter::BoolFilter(b) => {} // Potentially not doable.
        Filter::Aggregation(filter) => aggregation_filter(filter, invert)?,
        _ => todo!("Incomplete filter implementation."),
    };
    Ok(filter_pair)
}
pub ( crate ) fn convert_filter ( filter : Filter , invert : bool ) -> crate :: Result < MongoFilter > { let filter_pair = match filter { Filter :: And ( filters ) if invert => coerce_empty ( false , " " , filters , invert ) ? , Filter :: And ( filters ) => coerce_empty ( true , " " , filters , invert ) ? , Filter :: Or ( filters ) if invert => coerce_empty ( true , " " , filters , invert ) ? , Filter :: Or ( filters ) => coerce_empty ( false , " " , filters , invert ) ? , Filter :: Not ( filters ) if invert => coerce_empty ( false , " " , filters , ! invert ) ? , Filter :: Not ( filters ) => coerce_empty ( true , " " , filters , ! invert ) ? , Filter :: Scalar ( sf ) => scalar_filter ( sf , invert , true ) ? , Filter :: Empty => MongoFilter :: Scalar ( doc ! { } ) , Filter :: ScalarList ( slf ) => scalar_list_filter ( slf , invert ) ? , Filter :: OneRelationIsNull ( filter ) => one_is_null ( filter , invert ) , Filter :: Relation ( rfilter ) => relation_filter ( rfilter , invert ) ? , // Filter::BoolFilter(b) => {} // Potentially not doable. Filter :: Aggregation ( filter ) => aggregation_filter ( filter , invert ) ? , _ => todo ! ( " " ) , } ; Ok ( filter_pair ) }
Builds a MongoDB query filter from a Prisma filter.
Builds a MongoDB query filter from a Prisma filter .
filter
Filter
invert
bool