---
lang: en
title: 'API docs: filter.filterbuilder'
keywords: LoopBack 4.0, LoopBack 4, Node.js, TypeScript, OpenAPI
sidebar: lb4_sidebar
editurl: https://github.com/loopbackio/loopback-next/tree/master/packages/filter
permalink: /doc/en/lb4/apidocs.filter.filterbuilder.html
---

<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [@loopback/filter](./filter.md) &gt; [FilterBuilder](./filter.filterbuilder.md)

## FilterBuilder class

A builder for Filter. It provides fleunt APIs to add clauses such as `fields`<!-- -->, `order`<!-- -->, `where`<!-- -->, `limit`<!-- -->, `offset`<!-- -->, and `include`<!-- -->.

**Signature:**

```typescript
export declare class FilterBuilder<MT extends object = AnyObject> 
```

## Example


```ts
const filterBuilder = new FilterBuilder();
const filter = filterBuilder
  .fields('id', 'a', 'b')
  .limit(10)
  .offset(0)
  .order(['a ASC', 'b DESC'])
  .where({id: 1})
  .build();
```

## Constructors

<table><thead><tr><th>

Constructor


</th><th>

Modifiers


</th><th>

Description


</th></tr></thead>
<tbody><tr><td>

[(constructor)(f)](./filter.filterbuilder._constructor_.md)


</td><td>


</td><td>

Constructs a new instance of the `FilterBuilder` class


</td></tr>
</tbody></table>

## Properties

<table><thead><tr><th>

Property


</th><th>

Modifiers


</th><th>

Type


</th><th>

Description


</th></tr></thead>
<tbody><tr><td>

[filter](./filter.filterbuilder.filter.md)


</td><td>


</td><td>

[Filter](./filter.filter.md)<!-- -->&lt;MT&gt;


</td><td>


</td></tr>
</tbody></table>

## Methods

<table><thead><tr><th>

Method


</th><th>

Modifiers


</th><th>

Description


</th></tr></thead>
<tbody><tr><td>

[build()](./filter.filterbuilder.build.md)


</td><td>


</td><td>

Return the filter object


</td></tr>
<tr><td>

[fields(f)](./filter.filterbuilder.fields.md)


</td><td>


</td><td>

Describe what fields to be included/excluded


</td></tr>
<tr><td>

[impose(constraint)](./filter.filterbuilder.impose.md)


</td><td>


</td><td>

Add a Filter or Where constraint object. If it is a filter object, create an `and` clause for conflicting keys with its where object. For any other properties, throw an error. If it's not a Filter, coerce it to a filter, and carry out the same logic.


</td></tr>
<tr><td>

[include(i)](./filter.filterbuilder.include.md)


</td><td>


</td><td>

Declare `include`


</td></tr>
<tr><td>

[limit(limit)](./filter.filterbuilder.limit.md)


</td><td>


</td><td>

Set `limit`


</td></tr>
<tr><td>

[offset(offset)](./filter.filterbuilder.offset.md)


</td><td>


</td><td>

Set `offset`


</td></tr>
<tr><td>

[order(o)](./filter.filterbuilder.order.md)


</td><td>


</td><td>

Describe the sorting order


</td></tr>
<tr><td>

[skip(skip)](./filter.filterbuilder.skip.md)


</td><td>


</td><td>

Alias to `offset`


</td></tr>
<tr><td>

[where(w)](./filter.filterbuilder.where.md)


</td><td>


</td><td>

Declare a where clause


</td></tr>
</tbody></table>

