# Query Options

## **limit**

**Type:** `number`\
\
defines the maximum number of documents that the API will return for your query.\
`default: 25`  `max: 1000`

**Example usage:**

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

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

**Available for:**

* [Query all Documents](https://docs.comfortable.io/sdk/javascript/query-all-documents)
* [Query a Collection](https://docs.comfortable.io/sdk/javascript/query-a-collection)

## **offset**

**Type:** `number`\
defines the number of documents which gets skipped in the datasets.\
`default: 0`&#x20;

**Example usage:**

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

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

**Available for:**

* [Query all Documents](https://docs.comfortable.io/sdk/javascript/query-all-documents)
* [Query a Collection](https://docs.comfortable.io/sdk/javascript/query-a-collection)

## **locale**

**Type:** `string` \
set the Language for  the receiving documents. \
`locale: 'en'` \
to receive all languages, set `locale: 'all'`

**Example usage:**

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

api.getDocuments({
  locale: 'en'
})
  .then(result => {
    // futher implementation
  })
  .catch(err => {
    throw err;
  })
```

**Available for:**

* [Query all Documents](https://docs.comfortable.io/sdk/javascript/query-all-documents)
* [Query a Collection](https://docs.comfortable.io/sdk/javascript/query-a-collection)
* [Query a Single Document](https://docs.comfortable.io/sdk/javascript/query-a-single-document)
* [Query and Alias](https://docs.comfortable.io/sdk/javascript/query-an-alias)
* [Query an Asset](https://docs.comfortable.io/sdk/javascript/query-an-asset)

## **includes**

**Type:** `number`  or `Comfortable.Include` \
defines the aggregation level of related documents\
or pick specific relations which should be aggregated in the query results&#x20;

**Example picking specific relations:**

```javascript
var options = {
    includes: new Comfortable.Include()
        .add('relatedNews')
}
```

**Example with aggregation level:**

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

api.getDocuments({
  includes: 2 // aggregation level
})
  .then(result => {
    // futher implementation
  })
  .catch(err => {
    throw err;
  })
```

**Available for:**

* [Query all Documents](https://docs.comfortable.io/sdk/javascript/query-all-documents)
* [Query a Collection](https://docs.comfortable.io/sdk/javascript/query-a-collection)
* [Query a Single Document](https://docs.comfortable.io/sdk/javascript/query-a-single-document)
* [Query and Alias](https://docs.comfortable.io/sdk/javascript/query-an-alias)
* [Query an Asset](https://docs.comfortable.io/sdk/javascript/query-an-asset)

## **includeTags**

**Type:** `array` \
include documents with certain tags to the query results.

**Example usage:**

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

api.getDocuments({
  includeTags: ['include', 'me']
})
  .then(result => {
    // futher implementation
  })
  .catch(err => {
    throw err;
  })
```

**Available for:**

* [Query all Documents](https://docs.comfortable.io/sdk/javascript/query-all-documents)
* [Query a Collection](https://docs.comfortable.io/sdk/javascript/query-a-collection)

## **excludeTags**

**Type:** `array` \
exclude documents with certain tags from the query results.

**Example usage:**

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

api.getDocuments({
  excludeTags: ['exclude', 'this']
})
  .then(result => {
    // futher implementation
  })
  .catch(err => {
    throw err;
  })
```

**Available for:**

* [Query all Documents](https://docs.comfortable.io/sdk/javascript/query-all-documents)
* [Query a Collection](https://docs.comfortable.io/sdk/javascript/query-a-collection)

## **fields**

**Type:** `string` \
hiding/masking specific fields/parts from the query result.

```javascript
var options = {
    fields: 'meta,fields(title,date)'
}
```

**Example usage:**

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

api.getDocuments({
  fields: 'meta,fields(title)'
})
  .then(result => {
    // futher implementation
  })
  .catch(err => {
    throw err;
  })
```

**Available for:**

* [Query all Documents](https://docs.comfortable.io/sdk/javascript/query-all-documents)
* [Query a Collection](https://docs.comfortable.io/sdk/javascript/query-a-collection)
* [Query a Single Document](https://docs.comfortable.io/sdk/javascript/query-a-single-document)
* [Query and Alias](https://docs.comfortable.io/sdk/javascript/query-an-alias)
* [Query an Asset](https://docs.comfortable.io/sdk/javascript/query-an-asset)

## **embedAssets**

**Type:** `boolean` \
embeds assets to the document which points on them.

**Example usage:**

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

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

**Available for:**

* [Query all Documents](https://docs.comfortable.io/sdk/javascript/query-all-documents)
* [Query a Collection](https://docs.comfortable.io/sdk/javascript/query-a-collection)
* [Query a Single Document](https://docs.comfortable.io/sdk/javascript/query-a-single-document)
* [Query and Alias](https://docs.comfortable.io/sdk/javascript/query-an-alias)

## **filters**

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

**Example usage:**

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

api.getDocuments({
  filters: new Comfortable.Filter()
        .addAnd('title', 'like', '%Hello%')
        .addAnd('date', 'greaterThan', '2018-07-04')
        .addOr('topNews', 'equal', true)
})
  .then(result => {
    // futher implementation
  })
  .catch(err => {
    throw err;
  })
```

**Available for:**

* [Query all Documents](https://docs.comfortable.io/sdk/javascript/query-all-documents)
* [Query a Collection](https://docs.comfortable.io/sdk/javascript/query-a-collection)

## **sorting**

**Type:** `Comfortable.Sorting` \
sort query results ascending or descending by certain fields

**Example usage:**

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

api.getDocuments({
  sorting: new Comfortable.Sorting()
    .add('date', 'asc')
    .add('title', 'asc')
})
  .then(result => {
    // futher implementation
  })
  .catch(err => {
    throw err;
  })
```

**Available for:**

* [Query all Documents](https://docs.comfortable.io/sdk/javascript/query-all-documents)
* [Query a Collection](https://docs.comfortable.io/sdk/javascript/query-a-collection)

## **search**

**Type:** `string`&#x20;

**Example usage:**

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

api.getDocuments({
  search: 'sport -football +soccer'
})
  .then(result => {
    // futher implementation
  })
  .catch(err => {
    throw err;
  })
```

**Available for:**

* [Query all Documents](https://docs.comfortable.io/sdk/javascript/query-all-documents)
* [Query a Collection](https://docs.comfortable.io/sdk/javascript/query-a-collection)
