> For the complete documentation index, see [llms.txt](https://docs.comfortable.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.comfortable.io/sdk/javascript/example-filters.md).

# Example: Filters

Use the following query option to apply filters:

### **filters**

**Type:** `Comfortable.Filter` \
collect or reduce documents by certain field values&#x20;

```javascript
const api = Comfortable.api('<repository-api-id>', '<api-key>');

var options = {
    filters: new Comfortable.Filter()
        .addAnd('title', 'like', '%Hello%')
        .addAnd('date', 'greaterThan', '2018-07-04')
        .addOr('topNews', 'equal', true)
        /** filter by document id **/
        .addAnd('id', 'equals', '123123123432425', 'meta')
        /** filter blogPosts (contentType) by title **/
        .addAnd('title', 'like', '%Hello%', 'fields', 'blogPosts')
        
        // syntax
        // .addAnd(property: string(<id|title|...>), operator: string(<equals|like|...>), value: any, context: string(<fields|meta>), contentType: string(<*|contentTypeApiId>))
        // .addOr(property: string(<id|title|...>), operator: string(<equals|like|...>)), value: any, context: string(<fields|meta>), contentType: string(<*|contentTypeApiId>))
}

api.getDocuments(options)
  .then(result => {
    // futher implementation
  })
  .catch(err => {
    throw err;
  })
```
