Module type Rest.SERVICE
The SERVICE
interface has to be implemented by a CRUD service that drives the resource with its business logic.
val find : string -> t option Lwt.t
find id
returnst
if it is found.
val search : ?filter:string -> ?sort:[ `Desc | `Asc ] -> ?limit:int -> ?offset:int -> unit -> (t list * int) Lwt.t
search ?filter ?sort ?limit ?offset ()
returns a subset of the whole collection oft
. The returned tuple consist of the resulting subset and the total number oft
stored.filter
is an optional keyword that is used to apply a filter. Only items are shown wheret
containsfilter
in some form. The exact implementation is open, butfilter
should be used as general search keyword.sort
describes whether the result is sorted in descending or ascending order. The field that is sorted by and the default value are defined by the implementation for security reason.limit
is the number oft
in the resulting subset. A sane default is defined by the implementation.offset
is the number oft
skipped before the resulting subset. A sane default is defined by the implementation.
val insert : t -> (t, string) Result.t Lwt.t
insert t
insertst
and returns an error message that can be shown to the user if it fails.
val update : string -> t -> (t, string) Stdlib.result Lwt.t
update id t
updates the t that is found using itsid
witht
and returns an error message that can be shown to the user if it fails.This function is similar to
insert
and it overwrites an existingt
.
val delete : t -> (unit, string) Stdlib.result Lwt.t
delete t
deletest
and returns an error message that can be shown to the user if it fails.