Scope

class Scope<R : Resource>(resourceClass: KClass<R>, options: Scope<R>.() -> Unit = {})

A scope for querying the server.

Parameters

resourceClass

The resource to use the scope on.

options

The options for the scope.

Constructors

Link copied to clipboard
constructor(resourceClass: KClass<R>, options: Scope<R>.() -> Unit = {})

Types

Link copied to clipboard
annotation class ScopeMethod

Properties

Link copied to clipboard
val fields: <Error class: unknown class>

The fields to select.

Link copied to clipboard
val filter: <Error class: unknown class>

The filter options.

Link copied to clipboard
val includes: <Error class: unknown class>

The relationships to include.

Link copied to clipboard

The pagination options.

Link copied to clipboard
val params: <Error class: unknown class>

The extra parameters.

Link copied to clipboard
val sort: <Error class: unknown class>

The sort options.

Functions

Link copied to clipboard
suspend fun all(): CollectionProxy<R>

Get all the resources.

Link copied to clipboard
suspend fun exists(): Boolean

Check if any resource exists

Link copied to clipboard
fun extraParam(key: String, value: String): Scope<R>

Add an extra parameter to the request

Link copied to clipboard
suspend fun find(id: String): RecordProxy<R>

Find a resource by its ID

Link copied to clipboard
suspend fun findOrNull(id: String): RecordProxy<R?>

Find a resource by its ID or null if not found

Link copied to clipboard
suspend fun first(): RecordProxy<R>

Get the first resource

Link copied to clipboard
suspend fun firstOrNull(): RecordProxy<R?>

Get the first resource or null if not found

Link copied to clipboard
fun includes(vararg relationships: String): Scope<R>

Include the relationships in the response

Link copied to clipboard
suspend fun last(): RecordProxy<R>

Get the last resource

Link copied to clipboard
suspend fun lastOrNull(): RecordProxy<R?>

Get the last resource or null if not found

Link copied to clipboard
fun limit(limit: Number): Scope<R>

Set the number of items to return (Only for offset-based pagination)

Link copied to clipboard
fun offset(offset: Number): Scope<R>

Set the number of items to skip (Only for offset-based pagination)

Link copied to clipboard
fun order(attribute: String, sortDirection: SortDirection = SortDirection.ASC): Scope<R>

Order the resources by an attribute

Link copied to clipboard
fun page(pageNumber: Number): Scope<R>

Set the page number to return (Only for page-based pagination)

Link copied to clipboard
fun per(pageSize: Number): Scope<R>

Set the number of items per page (Only for page-based pagination)

Link copied to clipboard
fun select(type: String, vararg fields: String): Scope<R>

Select the fields to return

Link copied to clipboard
fun where(attribute: String, value: Any): Scope<R>

Filter the resources by an attribute