improve `LocalRepository` class:
In majority of cases, LocalRepository
is created from locally available array of object.
In order to use it with LocalRepository
developers write repetitive code of converting array of objects into TubCachedData structure.
Now it is possible to use it simply as:
const data = [
{code: '1', name: 'One'},
{code: '2', name: 'Two'}
]
const repo = UB.LocalRepository(data, 'frm_Attribute')
.attrs('code', 'name')
.orderBy('name')
// ...
As a bonus, the repository will be extended with mi_deleteDate set to max date (unless the objects contain mi_deleteDate with custom values),
and ONLY for entities which do not the mi_deleteDate
attribute.
LocalRepository now resembles somewhat TubDataStore.initialize
method https://git-pub.intecracy.com/unitybase/ubjs/-/blob/master/packages/ub/TubDataStore.js#L106, in a sense that it supports different type of "sources" for initialization - array of objects or TubCachedData.
ub-pub changed in a way, so that UB.LocalRepository
function now passes connection to the LocalRepository
class constructor, once connection established.
Though, LocalRepository
remains backward compatible for cases, when connection is not available, it just won't add mi_deleteDate automatically.
The new jsdocs type TubLocalData
is declared to make rowCount optional and avoid annoying IDE warnings, when in code rowCount
is actually not passed.