---
lang: en
title: 'API docs: repository.filterbuilder'
keywords: LoopBack 4.0, LoopBack 4
sidebar: lb4_sidebar
permalink: /doc/en/lb4/apidocs.repository.filterbuilder.html
---

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

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

## FilterBuilder class

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

<b>Signature:</b>

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

## Constructors

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

## Properties

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

## Methods

|  Method | Modifiers | Description |
|  --- | --- | --- |
|  [build()](./repository.filterbuilder.build.md) |  | Return the filter object |
|  [fields(f)](./repository.filterbuilder.fields.md) |  | Describe what fields to be included/excluded |
|  [impose(constraint)](./repository.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)](./repository.filterbuilder.include.md) |  | Declare <code>include</code> |
|  [limit(limit)](./repository.filterbuilder.limit.md) |  | Set <code>limit</code> |
|  [offset(offset)](./repository.filterbuilder.offset.md) |  | Set <code>offset</code> |
|  [order(o)](./repository.filterbuilder.order.md) |  | Describe the sorting order |
|  [skip(skip)](./repository.filterbuilder.skip.md) |  | Alias to <code>offset</code> |
|  [where(w)](./repository.filterbuilder.where.md) |  | Declare a where clause |

## 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();

```


