Skip to content

params

Operates on params as a whole, beyond the query — provider, route, pagination, custom keys.

NameCategoryDescription
paramsForServer
hooks

Client-side hook that moves whitelisted params properties into query._$client so they survive the client-to-server transport. The server only receives query from params — use paramsFromClient on the server to restore them.

paramsFromClient
hooks

Server-side hook that extracts whitelisted properties from query._$client back into context.params. This is the counterpart to paramsForServer, which encodes params on the client side for transport.

setSlug
hooks

Extracts URL route parameters (slugs) and sets them on params.query. For example, given a route /stores/:storeId, this hook copies the resolved storeId value from params.route into the query. Only applies to the rest provider.

stashable
hooks

Stashes the pre-mutation state of a record into context.params. Eagerly starts the fetch but exposes a memoized function — calling it multiple times only hits the database once. Use in before hooks on update, patch, or remove methods.

gateParams
utils

Selects and/or projects params keys according to a declarative path schema, returning a NEW object. General-purpose — no cache knowledge. Typically composed into the cache hook's transformParams option as (p) => gateParams(p, schema, opts).

Paths are resolved with lodash get/has and written with set, so nested values can be picked declaratively ('user.id': true).

params is never mutated: kept values are copied over by reference into the fresh result (safe, since the result is only read/serialized). The one exception is combining a top-level rule with a nested path under the SAME parent in one schema (e.g. { query: true, 'query.x': ... }) — the nested set would then write into the shared parent. Pick one granularity per parent to avoid it.

query is included as-is by DEFAULT (it is always relevant), unless the schema addresses it explicitly — either as query or a nested query.* path.

Keys not mentioned in the schema are KEPT by default, so forgetting a relevant key can only cause a harmless cache miss, never a false hit. Pass dropUnknownParams: true to keep only query and the schema paths.

getPaginate
utils

Resolves the active pagination options for the current hook context. Checks (in order): context.params.paginate, service.options.paginate, and context.params.adapter.paginate. Returns undefined if pagination is disabled.

stringifyParams
utils

Serializes Feathers params into a stable, deterministic string — built for generating cache keys.

Two normalizations make semantically-equal params produce the same string:

  • sortObject: object keys are sorted recursively.
  • sortArray: elements of query array operators ($or, $and, $nor, $not, $in, $nin) are order-normalized.

Serialization is crash-safe and never throws on values that leak through a params whitelist: circular references become [Circular], functions/undefined/symbol are dropped (like JSON.stringify), BigInt is stringified, and objects with toJSON (e.g. Date, bson ObjectId) are serialized via it.

transformParams
utils

Safely applies a transformParams function to a params object. If no function is provided, the original params are returned unchanged. The function receives a shallow copy of params, so the original is not mutated.

See all tags for the full vocabulary.

Released under the MIT License.