Repos¶
Repositories in this library are unified interfaces to work with different types of standard repos:
- CRUD (create/read/update/delete)
- Key-value
- Key-values
CRUD¶
Default interface for any CRUD
-oriented realization of repositories. This type of repos separated to three interfaces:
CRUDRepo
extends both ReadCRUDRepo
and WriteCRUDRepo
.
CRUD repos do not support forced placing of data by id when data is not in repo. That means, that you can’t set data in repo by id which absent in the repository.
ReadCRUDRepo
¶
Contains read-only operations, such as getById, contains. This interface can’t be observed because of it does not suppose any mutable operation.
WriteCRUDRepo
¶
Contains write-only operations, such as create, update. This interface can be observed via its flows:
- newObjectsFlow for newely created objects
- updatedObjectsFlow for old updated objects
- deletedObjectsIdsFlow for deleted objects
Info
By default, all mutating operations consumes List
s of data (List<New>
for create
, List<Pair<Id, New>>
for update
and List<Id>
for delete),
but all they have their extension function-variations with one/two args (like create
with New
arg)
create
operation consumes list ofNew
variants of object and producesRegistered
s list. In most cases,Registered
variant of object should haveId
of registered object, but it is not required for repo.update
operation consumes list of pairs withId
andNew
objects and produces list ofRegistered
objects.deleteById
operation consumes list ofId
s and do not consume anything except of notifying viadeletedObjectsIdsFlow
.
KeyValue¶
Key-value repos has been created to support work with classic key-value stores, where keys are unique across all the repo when values are not unique. As well as all the others types of repos, this one have two basic types: ReadKeyValueRepo and WriteKeyValueRepo
ReadKeyValueRepo¶
Read repo provides functions like: contains, get or values.
WritekeyValueRepo¶
Contains write-only operations. This interface can be observed via its flows:
- onNewValue to retrieve newely set values and keys
- onValueRemoved for the values removed from repo
Info
By default, all mutating operations consumes some collections. For example, set
require Map
with Key
s and Value
s and do not returns anything. Instead, it will throw notification via onNewValue
flow
All the methods on WriteKeyValueRepo
have their variances with pairs
(for set) or plain vararg
s.
set
operation consumes map ofKey
s and theirValue
s, set them and produces updates viaonNewValue
unset
operation consumes list ofKey
s, removingValue
byKey
and produces updates viaonValueRemoved
unsetWithValues
consumes list ofValue
s, removing allKey
s with theValue
s equal to one of the inputValue
s, and then produces updates viaonValueRemoved
KeyValues¶
This type of repos contains muliple Value
s by their unique Key
. It is not guaranteed, that Value
s list by any Key
will contains only unique values,
but in most cases Value
s list will not contains copies/same objects.
ReadKeyValuesRepo¶
Contains operations for work with value/values getting and checking. For example:
count for checking of amount of all values in repo
or values by key; get for getting of values by
pagination
.
WriteKeyValuesRepo¶
Contains write-only operations. This interface can be observed via its flows:
- onNewValue will pass
Key
andValue
whenValue
has been added to theKey
- onValueRemoved will pass
Key
andValue
whenValue
has been removed for theKey
- onDataCleared will pass
Key
when all its values has been removed by theclear
operation
Info
In difference with other repos, not all the methods of write key values repo require collections.
All the methods on WriteKeyValuesRepo
have their variances with pairs
(for set) or plain vararg
s.
add
will addValue
s to theirKey
s without any removing of dataclear
removes allValue
s byKey
andKey
itself from repoclearWithValue
removes allValue
with full clear of all data byKey
s with incomingValue
remove
consumesMap
ofKey
s and theValue
s which should be removed for eachKey
removeWithValue
will remove onlyValue
from allKey
s collections without their full wipeset
consumesMap
ofKey
s and theValue
s and will rewrite currently exists list ofValue
s and set theValue
s for theirKey