Collection Class
collection model of one model
Item Index
Methods
- $include
- $set
- $unset
- add
- add
- addItem
- addItems
- clear
- clear
- clone
- copyWith
- deprecated
- diff
- enum
- equals
- error
- every
- filter
- forEach
- getDiff
- getFacade deprecated
- getItemModelClass
- getModelProps
- getModule
- getParent
- include
- included
- inherit
- loaded
- map
- plainClone
- setEnum
- setIds
- setItems
- setRoot
- some
- toArray
- toPlainArray
- toPlainObject
- unset
Properties
- itemFactory
- itemModelName static
- items
- length
- root
Methods
$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
$unset
-
prop
unset property and create a new model
Parameters:
-
propStringproperty name
Returns:
this
add
-
...items
add submodels and create new collection
Parameters:
-
...itemsBaseModel | Object
Returns:
addItems
-
items
Parameters:
-
itemsObject | Array(BaseModel | Object)
clear
()
removes all items and ids
clear
()
removes all items and create a new collection
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
getDiff
-
plainObj -
[options]
Get diff prop values
Parameters:
-
plainObjAny -
[options]Object optional-
[ignores]Array(String) optionalprop names to skip checking diff
-
Returns:
getItemModelClass
()
Function
get item model
Returns:
getParent
()
Function
get parent class
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
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:
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
()
Array
public
export items to Array
Returns:
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.
itemModelName
String
protected
static
model name of the item
items
Object
items (submodel collection)
length
Number
public
the number of items (or ids when @isItemEntity is true)
