Comment on page
Example: Sorting
Use the following query option to apply sorting:
Type:
Comfortable.Sorting
sort query results ascending or descending by certain fieldsName | Default | Type | Description |
field API ID | | String | The field API ID sorting is applied to |
direction | desc | String | Sorting direction |
context | fields | String | Context can be either meta (meta fields) or fields (content fields) |
const api = Comfortable.api('<repository-api-id>', '<api-key>');
var options = {
sorting: new Comfortable.Sorting()
.add('createdAt', 'asc', 'meta')
.add('title', 'asc')
}
api.getDocuments(options)
.then(result => {
// futher implementation
})
.catch(err => {
throw err;
})
Last modified 4yr ago