---
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

|  Constructor | Modifiers | Description |
|  --- | --- | --- |
|  [(constructor)(f)](./filter.filterbuilder._constructor_.md) |  | Constructs a new instance of the <code>FilterBuilder</code> class |

## Properties

|  Property | Modifiers | Type | Description |
|  --- | --- | --- | --- |
|  [filter](./filter.filterbuilder.filter.md) |  | [Filter](./filter.filter.md)<!-- -->&lt;MT&gt; |  |

## Methods

|  Method | Modifiers | Description |
|  --- | --- | --- |
|  [build()](./filter.filterbuilder.build.md) |  | Return the filter object |
|  [fields(f)](./filter.filterbuilder.fields.md) |  | Describe what fields to be included/excluded |
|  [impose(constraint)](./filter.filterbuilder.impose.md) |  | Add a Filter or Where constraint object. If it is a filter object, create an <code>and</code> 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. |
|  [include(i)](./filter.filterbuilder.include.md) |  | Declare <code>include</code> |
|  [limit(limit)](./filter.filterbuilder.limit.md) |  | Set <code>limit</code> |
|  [offset(offset)](./filter.filterbuilder.offset.md) |  | Set <code>offset</code> |
|  [order(o)](./filter.filterbuilder.order.md) |  | Describe the sorting order |
|  [skip(skip)](./filter.filterbuilder.skip.md) |  | Alias to <code>offset</code> |
|  [where(w)](./filter.filterbuilder.where.md) |  | Declare a where clause |


