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:
-
prop
Stringproperty name
Returns:
this
add
-
...items
add submodels and create new collection
Parameters:
-
...items
BaseModel | Object
Returns:
addItems
-
items
Parameters:
-
items
Object | 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:
-
methodName
String -
message
String
Returns:
diff
-
plainObj
-
[options]
Get diff props
Parameters:
-
plainObj
Any -
[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:
-
reason
Stringreason of the error
-
[message]
String optional
Returns:
every
-
fn
-
_this
Returns if every items match the condition in given function
Parameters:
-
fn
Function -
_this
Object
Returns:
filter
-
fn
-
_this
Filter items with given function
Parameters:
-
fn
Function -
_this
Object
Returns:
forEach
-
fn
-
_this
Execute given function for each item
Parameters:
-
fn
Function -
_this
Object
getDiff
-
plainObj
-
[options]
Get diff prop values
Parameters:
-
plainObj
Any -
[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:
-
anotherModel
BaseModel
Returns:
this
loaded
()
Boolean
public
Returns:
map
-
fn
-
_this
Execute given function for each item returns an array of the result
Parameters:
-
fn
Function -
_this
Object
Returns:
plainClone
()
Object
public
clone the model as a plain object
Returns:
setEnum
-
prop
-
value
set enum value
Parameters:
-
prop
String -
value
String | Number
setIds
-
ids
clear and set ids.
Parameters:
-
ids
Array(String | Number)
setItems
-
items
clear and add items
Parameters:
-
items
Object | Array(BaseModel | Object)
setRoot
()
protected
some
-
fn
-
_this
Returns if some items match the condition in given function
Parameters:
-
fn
Function -
_this
Object
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)