BasicRelationship

BasicRelationship

new BasicRelationship()

Properties:
Name Type Description
name string The relationship name
type string The relationship type (belongsTo, hasMany, hasOne)
hasApi boolean Determines if the relationship has api endpoints
parentKey Field The relationship parent model key
foreignKey Field The relationship foreign key
localModel Entity The model that owns the relationship
model Entity The related model
inputs Array.<Input> All inputs of the relationship
hasManyDetails HasManyDetail The related detail components (for Master-Detail)
inverse BasicRelationship The inverse relationship

Methods

belongsToModel(model) → {Entity}

Returns if a model belongs to another
Parameters:
Name Type Description
model Entity
Returns:
Type
Entity

getApiRoutes() → {array}

Returns the relationship api routes
Returns:
Type
array

getControllerName() → {string}

Returns the controller name
Returns:
Type
string

getDefaultForeignKeyName() → {string}

Returns the original foreign key name
Returns:
Type
string

getDefaultKeysNames() → {object}

Returns primary key based on relationship keys
Returns:
Type
object

getForeignModel() → {Entity}

Returns the foreign model
Returns:
Type
Entity

getParentModel() → {Entity}

Returns the parent model
Returns:
Type
Entity

hasDifferentForeignKey() → {boolean}

If the relationship has a non-standard foreign key
Returns:
Type
boolean

hasDifferentForeignOrParentKey() → {boolean}

If the relationship has non-standard foreign or parent key
Returns:
Type
boolean

hasDifferentParentKey() → {boolean}

If the relationship has parent key different from 'id'
Returns:
Type
boolean

isBelongsTo() → {boolean}

If the relationship is a belongsTo
Returns:
Type
boolean

isHasMany() → {boolean}

If the relationship is a hasMany
Returns:
Type
boolean

isHasOne() → {boolean}

If the relationship is a hasOne
Returns:
Type
boolean