RestEntity

class RestEntity<T, I>(resource: Resource<T, I>, initialId: I, contentType: String, remote: Request) : EntityRepository<T, I>

provides crud-functions 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.

Constructors

RestEntity
Link copied to clipboard
js
fun <T, I> RestEntity(resource: Resource<T, I>, initialId: I, contentType: String, remote: Request)
definition of the Resource

Functions

addOrUpdate
Link copied to clipboard
js
open suspend override fun addOrUpdate(entity: T): 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(entity: T)
deletes an entity by a delete-request to resource.
load
Link copied to clipboard
js
open suspend override fun load(id: I): T
loads an entity by a get request to resource/{id}

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