View Source FatEcto.FatQuery.WhereableHelper (FatEcto v1.0.0)

Provides helper functions for filtering and processing query parameters.

Summary

Functions

Filters fields in params based on the provided filterable_fields map.

Filters overrideable fields based on the provided overrideable_fields list and ignoreable_fields_values.

Removes fields from where_params if their values match any of the values in ignoreable_fields_values.

Functions

filter_filterable_fields(params, filterable_fields)

@spec filter_filterable_fields(map(), map()) :: map()

Filters fields in params based on the provided filterable_fields map.

Parameters

  • params: A map containing the fields, operators, and values to filter.
  • filterable_fields: A map containing allowed fields and their corresponding operators.

Returns

A filtered map containing only the fields and operators that are allowed.

filter_overrideable_fields(params, overrideable_fields, ignoreable_fields_values)

@spec filter_overrideable_fields(map(), list(), map()) :: [map()]

Filters overrideable fields based on the provided overrideable_fields list and ignoreable_fields_values.

Parameters

  • params: A map containing the fields, operators, and values to filter.
  • overrideable_fields: A list of fields that can be overridden.
  • ignoreable_fields_values: A map containing fields and their ignoreable values.

Returns

A list of maps containing filtered fields, operators, and values.

remove_ignoreable_fields(where_params, ignoreable_fields_values)

@spec remove_ignoreable_fields(map(), map()) :: map()

Removes fields from where_params if their values match any of the values in ignoreable_fields_values.

Parameters

  • where_params: A map containing the fields, operators, and values to filter.
  • ignoreable_fields_values: A map containing fields and their ignoreable values (can be a single value or a list of values).

Returns

A filtered map with ignoreable fields removed.