addToQuery
utils
Source Code | DocumentationSafely merges properties into a Feathers query object. If a property already exists with a different value, it wraps both in a $and array to preserve both conditions. If the exact same key-value pair already exists, no changes are made.
ts
import { addToQuery } from 'feathers-utils/utils';Example
ts
import { addToQuery } from 'feathers-utils/utils'
const query = { status: 'active' }
addToQuery(query, { role: 'admin' })
// => { status: 'active', role: 'admin' }Type declaration
Show Type Declarations
ts
/**
* Safely merges properties into a Feathers query object. If a property already exists
* with a different value, it wraps both in a `$and` array to preserve both conditions.
* If the exact same key-value pair already exists, no changes are made.
*
* @example
* ```ts
*
*
* const query = { status: 'active' }
* addToQuery(query, { role: 'admin' })
* // => { status: 'active', role: 'admin' }
* ```
*
* @see https://utils.feathersjs.com/utils/add-to-query.html
*/
export declare function addToQuery<Q extends Query>(targetQuery: Q, query: Q): Q| Argument | Type | Description |
|---|---|---|
| targetQuery | Q | |
| query | Q |
