removeMany
Category
Tags
Export size
min 1.19 kB · gzip 0.63 kB
See also
Removes all items matching params with a single remove(null, ...) call.
If the service does not allow multi removing (its multi option, or an explicit multi option), the matching items are fetched with find and removed with one call per item instead - so it works regardless of the service's multi configuration.
The params only select which items are affected: the query is consumed by the find - which only collects the ids - and is not applied again for the per-item calls, except $select.
ts
import { removeMany } from 'feathers-utils/utils';Example
ts
import { removeMany } from 'feathers-utils/utils'
// one `remove(null, ...)` call, or one `remove(id, ...)` call per item
const todos = await removeMany(app, 'todos', { query: { userId: 1 } })Type declaration
Show Type Declarations
ts
export type RemoveManyOptions = {
/**
* Whether the service allows removing multiple items in a single call.
*
* Defaults to the `multi` option of the service. If multi removing is not
* allowed, the matching items are fetched and removed with one call per item.
*/
multi?: Multi
}
/**
* Removes all items matching `params` with a single `remove(null, ...)` call.
*
* If the service does not allow multi removing (its `multi` option, or an
* explicit `multi` option), the matching items are fetched with `find` and
* removed with one call per item instead - so it works regardless of the
* service's `multi` configuration.
*
* The `params` only select which items are affected: the query is consumed by
* the `find` - which only collects the ids - and is not applied again for the
* per-item calls, except `$select`.
*
* @example
* ```ts
*
*
* // one `remove(null, ...)` call, or one `remove(id, ...)` call per item
* const todos = await removeMany(app, 'todos', { query: { userId: 1 } })
* ```
*
* @see https://utils.feathersjs.com/utils/remove-many.html
*/
export declare function removeMany<
Services,
Path extends KeyOf<Services>,
Service extends Services[Path] = Services[Path],
P extends Params = InferFindParams<Service>,
Item = InferFindResultSingle<Service>,
>(
app: Application<Services>,
servicePath: Path,
params?: P,
options?: RemoveManyOptions,
): Promise<Item[]>| Argument | Type | Description |
|---|---|---|
| app | Application<Services> | |
| servicePath | Path | |
| params | P | |
| options | RemoveManyOptions |
