Skip to content

Retrieving

DavidDuwaer edited this page Sep 1, 2017 · 13 revisions

Query building

Running a query

Running a query retrieving multiple objects

The most simple query is to retrieve all objects of a certain kind.

Artist.get()

Because this is not a database query but an API query, results of multiple objects are always paginated. Artist.get() retrieves the first page. Other pages are retrieved like this:

Artist.get(3)

...which retrieves the third page. The default page size of the underlying API can be overridden; how this is done is explained here.

Running a query retrieving a single object

A single object can be retrieved either by ID

Artist.find(123)

Which can also be a string

Artist.find('tomaskalnoky')

Or a single object is retrieved by taking only the first result of some query

Artist.first()

Filtering

A filter can be applied on a property of the object you are trying to retrieve.

Artist
    .where('gender', 'm')
    .get()

Sorting

Limiting

The response object

Clone this wiki locally