Builder for Humaans API filter query parameters.
The Humaans API (a Feathers.js application) supports filtering list
endpoints with operator suffixes like $in, $gt, etc. Hand-encoding
these in keyword lists is awkward in Elixir because the keys contain
characters that don't survive atom literals, e.g.
["status[$in]": ["active"]]. This module provides a small chainable
builder so callers can express filters readably.
Field names and operator suffixes are stored as strings in the resulting params list. This avoids creating new atoms at runtime — important because atoms are not garbage-collected and untrusted or high-cardinality field names could otherwise exhaust the atom table. Req accepts string-keyed params transparently, so callers do not need to do anything different.
Example
query =
Humaans.Query.new()
|> Humaans.Query.eq(:companyId, "acme")
|> Humaans.Query.in_(:status, ["active", "onboarding"])
|> Humaans.Query.gte(:createdAt, "2025-01-01")
|> Humaans.Query.to_params()
Humaans.People.list(client, query)Supported operators
eq/3— exact match (no operator suffix)in_/3—$in(any of)nin/3—$nin(none of)gt/3—$gtgte/3—$gtelt/3—$ltlte/3—$lte
Field names are accepted as atoms or strings. The Humaans API uses
camelCase field names (companyId, createdAt, etc.) — pass them as
written. Operator-suffixed keys are produced for you.
Use merge/2 to combine a query with other params (e.g. pagination):
Humaans.Query.new()
|> Humaans.Query.in_(:status, ["active"])
|> Humaans.Query.merge("$limit": 50)
|> Humaans.Query.to_params()
Summary
Functions
Adds an equality filter (field=value).
Adds a $gt filter.
Adds a $gte filter.
Adds a $in filter (field[$in]=value).
Adds a $lt filter.
Adds a $lte filter.
Merges arbitrary params (keyword list or another query) into this query.
Returns an empty query.
Adds a $nin filter.
Returns the query as a list of {string_key, value} tuples suitable for
passing as params to a resource list function.
Types
Functions
Adds an equality filter (field=value).
Adds a $gt filter.
Adds a $gte filter.
Adds a $in filter (field[$in]=value).
Adds a $lt filter.
Adds a $lte filter.
Merges arbitrary params (keyword list or another query) into this query.
Useful for combining filters with pagination params. Atom keys in the keyword list are normalized to strings so the result is uniform.
Raises ArgumentError when given a list that is not a proper keyword
list (e.g. contains non-tuple elements or non-atom keys).
@spec new() :: t()
Returns an empty query.
Adds a $nin filter.
Returns the query as a list of {string_key, value} tuples suitable for
passing as params to a resource list function.