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

contentType

to be used by the REST-API

initialId

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

remote

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

resource

definition of the Resource

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.
equals
Link copied to clipboard
js
open operator fun equals(other: Any?): Boolean
hashCode
Link copied to clipboard
js
open fun hashCode(): Int
load
Link copied to clipboard
js
open suspend override fun load(id: I): T
loads an entity by a get request to resource/{id}
toString
Link copied to clipboard
js
open fun toString(): String

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