BaseDict Class
dictionary-structured data model
Item Index
Methods
- $append
- $include
- $remove
- $replace
- $set
- $unset
- add
- addItem
- addItems
- clear
- clone
- contains
- copyWith
- deprecated
- diff
- enum
- equals
- error
- every
- filter
- forEach
- get
- getDiff
- getFacade deprecated
- getItem
- getItemModelClass
- getModelProps
- getModule
- getParent
- has
- include
- included
- inherit
- initItems
- key static
- keys
- keyValues
- loaded
- map
- plainClone
- remove
- setEnum
- setIds
- setItems
- setRoot
- some
- toArray
- toggle
- toggle
- toObject
- toPlainArray
- toPlainObject
- unset
Properties
Methods
$append
-
item
replace or add item and return a new dict
Parameters:
-
itemBaseModel
Returns:
newDict
$include
-
[options]
include all relational models and returns new model
Parameters:
-
[options]Object optional-
[async=true]Boolean optionalget async values
-
[props]Array(String) optionalinclude only given props
-
Returns:
new model
$remove
-
item
remove submodel and create a new dict both acceptable, keys and submodels
Parameters:
-
itemBaseModel | String | Number
Returns:
newDict
$replace
-
item
replace item and return a new dict
Parameters:
-
itemBaseModel
Returns:
newDict
$unset
-
prop
unset property and create a new model
Parameters:
-
propStringproperty name
Returns:
this
addItems
-
items
Parameters:
-
itemsObject | Array(BaseModel | Object)
clear
()
removes all items and ids
contains
-
item
check if the model contains the given submodel or not
Parameters:
-
itemBaseModel
Returns:
deprecated
-
methodName -
message
Show indication message of deprecated method
Parameters:
-
methodNameString -
messageString
Returns:
diff
-
plainObj -
[options]
Get diff props
Parameters:
-
plainObjAny -
[options]Object optional-
[ignores]Array(String) optionalprop names to skip checking diff
-
Returns:
enum
()
Object(key: String => Number)
public
Returns:
error
-
reason -
[message]
create instance of DomainError
Parameters:
-
reasonStringreason of the error
-
[message]String optional
Returns:
every
-
fn -
_this
Returns if every items match the condition in given function
Parameters:
-
fnFunction -
_thisObject
Returns:
filter
-
fn -
_this
Filter items with given function
Parameters:
-
fnFunction -
_thisObject
Returns:
forEach
-
fn -
_this
Execute given function for each item
Parameters:
-
fnFunction -
_thisObject
get
-
key
return submodel of the given key
Parameters:
-
keyString | Number
Returns:
getDiff
-
plainObj -
[options]
Get diff prop values
Parameters:
-
plainObjAny -
[options]Object optional-
[ignores]Array(String) optionalprop names to skip checking diff
-
Returns:
getItem
-
key
return submodel of the given key throw error when not found.
Parameters:
-
keyString | Number
Returns:
getItemModelClass
()
Function
get item model
Returns:
getParent
()
Function
get parent class
Returns:
has
-
key
check if the model has submodel of the given key or not
Parameters:
-
keyString | Number
Returns:
include
-
[options]
include all relational models if not set
Parameters:
-
[options]Object optional-
[async=true]Boolean optionalget async values
-
[props]Array(String) optionalinclude only given props
-
Returns:
self
included
()
Boolean
Check if all subentities are included.
Returns:
inherit
-
anotherModel
inherit value of anotherModel
Parameters:
-
anotherModelBaseModel
Returns:
this
initItems
()
protected
key
()
protected
static
get unique key from item
keys
()
Array
public
get all keys
Returns:
keyValues
-
fn
iterate key - item
Parameters:
-
fnFunction1st argument: key, 2nd argument: value
loaded
()
Boolean
public
Returns:
map
-
fn -
_this
Execute given function for each item returns an array of the result
Parameters:
-
fnFunction -
_thisObject
Returns:
plainClone
()
Object
public
clone the model as a plain object
Returns:
remove
-
item
remove submodel from items both acceptable, keys and submodels
Parameters:
-
itemBaseModel | String | Number
setEnum
-
prop -
value
set enum value
Parameters:
-
propString -
valueString | Number
setIds
-
ids
clear and set ids.
Parameters:
-
idsArray(String | Number)
setItems
-
items
clear and add items
Parameters:
-
itemsObject | Array(BaseModel | Object)
setRoot
()
protected
some
-
fn -
_this
Returns if some items match the condition in given function
Parameters:
-
fnFunction -
_thisObject
Returns:
toArray
()
public
export models to Array
toggle
-
item
turn on/off the value and create a new model
Parameters:
-
itemBaseModel
Returns:
newDict
toObject
()
public
to key-value object
toPlainArray
()
Array
create plain array.
Returns:
plainArray
toPlainObject
()
Object
create plain object. if this dict contains entities, returns their ids if this dict contains non-entity models, returns their plain objects
Returns:
plainObject
Properties
itemFactory
FactoryInterface
item factory Created only one time. Be careful that @root is not changed even the collection's root is changed.
itemLength
Number
public
the number of items
items
Object
items: dictionary of keys - models
length
Number
public
the number of items (or ids when @isItemEntity is true)
