FatEcto.Query.Helper (FatEcto v1.2.0)

View Source

Provides helper functions for filtering and processing query parameters in FatEcto.Query.Dynamics.Buildable.

Summary

Functions

Filters fields based on the filterable_fields configuration.

Removes fields with ignoreable values from the query parameters.

Functions

filter_filterable_fields(where_params, filterable_fields, overrideable_fields)

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

Filters fields based on the filterable_fields configuration.

Parameters

  • where_params: The query parameters (e.g., %{"field" => %{"$EQUAL" => "value"}}).
  • filterable_fields: A keyword list of fields and their allowed operators (e.g., [name: ["$EQUAL"], age: "*"]).
  • overrideable_fields: A list of fields that can be overridden (e.g., ["phone"]).

Returns

  • The filtered query parameters.

remove_ignoreable_fields(where_params, ignoreable_fields_values)

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

Removes fields with ignoreable values from the query parameters.

Parameters

  • where_params: The query parameters (e.g., %{"field" => %{"$EQUAL" => "value"}}).
  • ignoreable_fields_values: A keyword list of fields and their ignoreable values (e.g., [email: ["", "%%", nil], phone: [nil]]).

Returns

  • The filtered query parameters.