RestQuery

class RestQuery<T, I, Q>(resource: Resource<T, I>, initialId: I, contentType: String, remote: Request, buildQuery: suspend Request.(Q) -> Response) : QueryRepository<T, I, Q>

provides services to deal with queries for REST-API to a defined Resource

Parameters

resource

definition of the Resource

initialId

id to compare a given resource for differentiation of adding or updating

contentType

to be used by the REST-API

remote

base Request to be used by all subsequent requests. Use it to configure authentication, etc.

buildQuery

function to build a Request for a given object defining the query

Constructors

RestQuery
Link copied to clipboard
js
fun <T, I, Q> RestQuery(resource: Resource<T, I>, initialId: I, contentType: String, remote: Request, buildQuery: suspend Request.(Q) -> Response)
definition of the Resource

Functions

addOrUpdate
Link copied to clipboard
js
open suspend override fun addOrUpdate(entities: List<T>, entity: T): List<T>
sends a post-(for add) or a put-(for update) request to remote/{id} with the serialized entity in it's body.
delete
Link copied to clipboard
js
open suspend override fun delete(entities: List<T>, id: I): List<T>
deletes one entity from the list
open suspend override fun delete(entities: List<T>, ids: List<I>): List<T>
deletes multiple entities from the list
query
Link copied to clipboard
js
open suspend override fun query(query: Q): List<T>
queries the resource by sending the request which is build by buildQuery using the query
updateMany
Link copied to clipboard
js
open suspend override fun updateMany(entities: List<T>, entitiesToUpdate: List<T>): List<T>
updates given entities in the entities list (sending a put-request to the base-url of the resource for every updated entity)

Properties

contentType
Link copied to clipboard
js
val contentType: String
to be used by the REST-API
initialId
Link copied to clipboard
js
val initialId: I
id to compare a given resource for differentiation of adding or updating