z_search_props (zotonic_core v1.0.0-rc.17)

Map query args to query maps and vice versa. Special backwards compatible handling for repeating terms with the same name.

Summary

Functions

Add default search terms if they do not exist in the original query terms.

Translate the query arguments to a query term map. Drops query terms with empty values, as unselected or empty inputs in search forms can post empty values.

Translate a map with query term keys to a query term map.

Translate the query arguments to a query term map.

Translate a stored query text to a query term map.

Functions

default_terms(Q, Defaults)

Add default search terms if they do not exist in the original query terms.

from_list(Args)

-spec from_list(Args) -> Query
                   when
                       Args :: [KeyValue],
                       KeyValue :: {Key, Value} | Key | list(),
                       Key :: binary() | atom(),
                       Value :: binary() | number() | boolean() | list(),
                       Query :: map().

Translate the query arguments to a query term map. Drops query terms with empty values, as unselected or empty inputs in search forms can post empty values.

from_map(TermMap)

-spec from_map(TermMap) -> Query when TermMap :: map(), Query :: map().

Translate a map with query term keys to a query term map.

from_qargs(QArgs)

-spec from_qargs(QArgs) -> Query
                    when
                        QArgs :: z:context() | [{Key, Value}],
                        Key :: binary() | atom(),
                        Value :: binary() | number() | boolean() | list(),
                        Query :: map().

Translate the query arguments to a query term map.

from_text(Text)

-spec from_text(Text) -> Query when Text :: binary() | string() | undefined, Query :: map().

Translate a stored query text to a query term map.