Namespace: query

query

Selection query as defined by JSData's Query Syntax.

Details
Since Source Tutorials
3.0.0 Query.js, line 278
Properties:
Name Type Argument Description
limit Number <optional>

See query.limit.

offset Number <optional>

See query.offset.

orderBy String | Array.<Array> <optional>

See query.orderBy.

skip Number <optional>

Alias for query.offset.

sort String | Array.<Array> <optional>

Alias for query.orderBy.

where Object <optional>

See query.where.

Examples

Empty "findAll" query

store.findAll('post').then((posts) => {
  console.log(posts) // [...]
})

Empty "filter" query

const posts = store.filter('post')
console.log(posts) // [...]

Complex "findAll" query

const PAGE_SIZE = 10
let currentPage = 3

// Retrieve a filtered page of blog posts
store.findAll('post', {
  where: {
    status: {
      // WHERE status = 'published'
      '==': 'published'
    },
    author: {
      // AND author IN ('bob', 'alice')
      'in': ['bob', 'alice'],
      // OR author IN ('karen')
      '|in': ['karen']
    }
  },
  orderBy: [
    // ORDER BY date_published DESC,
    ['date_published', 'DESC'],
    // ORDER BY title ASC
    ['title', 'ASC']
  ],
  // LIMIT 10
  limit: PAGE_SIZE,
  // SKIP 20
  offset: PAGE_SIZE * (currentPage 1)
}).then((posts) => {
  console.log(posts) // [...]
})

Members


<static> limit

Maximum number of records to retrieve.

Example

Retrieve the first "page" of blog posts

const PAGE_SIZE = 10
let currentPage = 1
PostService.findAll({
  offset: PAGE_SIZE * (currentPage 1)
  limit: PAGE_SIZE
})

<static> offset

Number of records to skip.

Example

Retrieve the first "page" of blog posts

const PAGE_SIZE = 10
let currentPage = 1
PostService.findAll({
  offset: PAGE_SIZE * (currentPage 1)
  limit: PAGE_SIZE
})

<static> orderBy

Determines how records should be ordered in the result.

Details
Type Since Source See
String | Array.<Array> 3.0.0 Query.js, line 386
Example
TODO

<static> where

Filtering criteria. Records that do not meet this criteria will be exluded from the result.

Example
TODO