Entity

Entity

new Entity()

Geml entity

Source:

Members

comment :string

Source:
Type:
  • string

displayName :string

Source:
Type:
  • string

fields :object.<string, Field>

Fields of the entity, map of <fieldName, fieldObject>

Source:
Type:

info :Object

Raw metadata

Source:
Type:
  • Object

linker :Linker

Linker to process this entity

Source:
Type:

name :string

Name of this entity

Source:
Type:
  • string

types

Referenced types

Source:

xemlModule :object

Owner geml module

Source:
Type:
  • object

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

addIndexes()

Add all indexes

Source:

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

getKeyField() → {*}

Get key field

Source:
Returns:
Type:
*

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

Start linking this entity

Source:
Returns:
Type:
Entity

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

Type Definitions

eventListener()

Entity event listener

Source:

Entity

new Entity(linker, name, xemlModule, info)

Source:
Parameters:
Name Type Description
linker Linker
name string
xemlModule *
info object

Members

comment :string

Source:
Type:
  • string

displayName :string

Source:
Type:
  • string

fields :object.<string, Field>

Fields of the entity, map of <fieldName, fieldObject>

Source:
Type:

info :Object

Raw metadata

Source:
Type:
  • Object

linker :Linker

Linker to process this entity

Source:
Type:

name :string

Name of this entity

Source:
Type:
  • string

types

Referenced types

Source:

xemlModule :object

Owner geml module

Source:
Type:
  • object

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

addIndexes()

Add all indexes

Source:

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

getKeyField() → {*}

Get key field

Source:
Returns:
Type:
*

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

Start linking this entity

Source:
Returns:
Type:
Entity

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

Type Definitions

eventListener()

Entity event listener

Source: