Members
fields :object.<string, Field>
Fields of the entity, map of <fieldName, fieldObject>
- Source:
Type:
-
object.<string, Field>
Methods
addAssocField(name, destEntity, destField)
Add a association field.
- Source:
Parameters:
Name | Type | Description |
---|---|---|
name |
string
|
|
destEntity |
Entity
|
|
destField |
Field
|
addAssociation(name, props)
Add association, dbms-specific
- Source:
Parameters:
Name | Type | Description |
---|---|---|
name |
*
|
|
props |
*
|
Example
e.g. mysql
entity - Associated entity name
join - Join type, e.g. INNER, LEFT, RIGHT, OUTER
exclude - Exclude in output columns
alias - Alias
on - On conditions
dataset - Sub query
assocs - Child associations
optional - Optional
'default' - Default value
list - Is a list
addFeature(name, feature, allowMultipleopt) → {Entity}
Add a feature into the entity, e.g. auto increment id
- Source:
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
name |
string
|
|||
feature |
*
|
|||
allowMultiple |
bool
|
<optional> |
false |
Allow multiple occurrence |
Returns:
- Type:
-
Entity
addField(name, rawInfo) → {Entity}
Add a field into the entity
- Source:
Parameters:
Name | Type | Description |
---|---|---|
name |
string
|
|
rawInfo |
object
|
Returns:
- Type:
-
Entity
addIndex(index) → {Entity}
Add an index
Properties:
Name | Type | Description |
---|---|---|
index.fields |
array
|
Fields of the index |
index.unique |
bool
|
Flag of uniqueness of the index |
- Source:
Parameters:
Name | Type | Description |
---|---|---|
index |
object
|
Returns:
- Type:
-
Entity
clone(stackopt) → {Entity}
Clone the entity
- Source:
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
stack |
Map
|
<optional> |
Reference stack to avoid recurrence copy |
Returns:
- Type:
-
Entity
getEntityAttribute(fieldId) → {Field}
Get a field object by field name or entity meta accesor (e.g. $key, $feature).
- Source:
Parameters:
Name | Type | Description |
---|---|---|
fieldId |
Returns:
- Type:
-
Field
getReferenceTo()
Returns the association info if there is connection to the given destination entity.
- Source:
hasField(name) → {boolean}
Check whether the entity has a field with given name
- Source:
Parameters:
Name | Type | Description |
---|---|---|
name |
string
|
Returns:
- Type:
-
boolean
hasIndexOn(fields) → {boolean}
Check whether the entity has an index on the given fields
- Source:
Parameters:
Name | Type | Description |
---|---|---|
fields |
array
|
Returns:
- Type:
-
boolean
once(eventName, listener) → {EventEmitter}
Listen on an event
- Source:
Parameters:
Name | Type | Description |
---|---|---|
eventName |
string
|
|
listener |
Entity.eventListener
|
Returns:
- Type:
-
EventEmitter
setKey(name) → {Entity}
Set key name
- Source:
Parameters:
Name | Type | Description |
---|---|---|
name |
string
|
array.<string>
|
Field name to be used as the key |
Returns:
- Type:
-
Entity
toJSON() → {object}
Translate the entity into a plain JSON object
- Source:
Returns:
- Type:
-
object