Comfortable | Docs
  • Comfortable Documentation
  • Concepts
    • Content Repositories
    • Content Types
    • Documents
    • Assets
    • Content Tree
    • Collections
    • Webhooks
    • Team
    • Locales
  • APIs
    • RESTful API
      • Endpoints
      • API Reference
        • Sorting
        • Filters
        • Localisation
        • Fields
        • Includes
        • Search
      • Query Examples
        • Collections
        • Single Documents
        • Single Assets
        • Sorting
        • Filters
        • Includes
    • Image Manipulation
  • SDKs
    • JavaScript
      • Query Options
      • Query All Documents
      • Query a Collection
      • Query a Single Document
      • Query an Alias
      • Query an Asset
      • Example: Filters
      • Example: Sorting
    • Nuxt.js
    • PHP
      • Query All Documents
      • Query Single Document
      • Query Collection
      • Query an Alias
      • Query an Asset
      • Fulltext Search
      • Query by Fields
      • Query by Type
      • Query by Id
      • Query by Tags
  • Guides
    • Vue Blog Example
  • Legal
    • Legal Notice
    • Privacy Policy
Powered by GitBook
On this page
  • limit
  • offset
  • locale
  • includes
  • includeTags
  • excludeTags
  • fields
  • embedAssets
  • filters
  • sorting
  • search
  1. SDKs
  2. JavaScript

Query Options

PreviousJavaScriptNextQuery All Documents

Last updated 6 years ago

limit

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

Example usage:

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

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

Available for:

offset

Type: number defines the number of documents which gets skipped in the datasets. default: 0

Example usage:

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

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

Available for:

locale

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

Example usage:

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

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

Available for:

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

Example picking specific relations:

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

Example with aggregation level:

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:

includeTags

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

Example usage:

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

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

Available for:

excludeTags

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

Example usage:

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

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

Available for:

fields

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

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

Example usage:

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:

embedAssets

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

Example usage:

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

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

Available for:

filters

Type: Comfortable.Filter collect or reduce documents by certain field values

Example usage:

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:

sorting

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

Example usage:

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:

search

Type: string

Example usage:

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
Query a Collection
Query all Documents
Query a Collection
Query all Documents
Query a Collection
Query a Single Document
Query and Alias
Query an Asset
Query all Documents
Query a Collection
Query a Single Document
Query and Alias
Query an Asset
Query all Documents
Query a Collection
Query all Documents
Query a Collection
Query all Documents
Query a Collection
Query a Single Document
Query and Alias
Query an Asset
Query all Documents
Query a Collection
Query a Single Document
Query and Alias
Query all Documents
Query a Collection
Query all Documents
Query a Collection
Query all Documents
Query a Collection