quick.models.Relationships

Class HasMany

lucee.Component
    extended by quick.models.Relationships.BaseRelationship
      extended by quick.models.Relationships.HasOneOrMany
        extended by quick.models.Relationships.HasMany

Represents a hasMany relationship. This is a relationship where the parent entity has zero or more of the related entity. The inverse of this relationship is a `belongsTo` relationship. For instance, a `User` may have zero or more `Post` associated to them. This would be modeled in Quick by adding a method to the `User` entity that returns a `HasMany` relationship instance. ``` function posts() { returns hasMany( "Post" ); } ```

Class Attributes:
  • synchronized : false
  •  
  • accessors : true
  •  
  • persistent : false
  •  
    Method Summary
    array<BaseEntity> getResults()
         Returns the result of the relationship.
    array<BaseEntity> initRelation(array entities, string relation)
         Initializes the relation to the null value for each entity in an array.
    array<BaseEntity> match(array entities, array results, string relation)
         Matches the array of entity results to an array of entities for a relation.
     
    Methods inherited from class quick.models.Relationships.HasOneOrMany
    addConstraints, addEagerConstraints, applySetter, applyThroughExists, applyThroughJoin, buildDictionary, create, getForeignKeys, getLocalKeys, getParentKeys, getQualifiedForeignKeyNames, getQualifiedLocalKeys, getRelationValue, init, initialThroughConstraints, matchMany, matchOne, matchOneOrMany, save, saveMany, setForeignAttributesForCreate, setForeignKeys, setLocalKeys
     
    Methods inherited from class quick.models.Relationships.BaseRelationship
    addCompareConstraints, all, applyAliasSuffix, arrayWrap, arrayZipEach, fieldsAreNull, find, findOrFail, first, firstOrFail, get, getDefaultAttributes, getEager, getExistanceLocalKeys, getExistenceCompareKeys, getKeys, getParent, getRelated, getRelationMethodName, getRelationName, getReturnDefaultEntity, getWirebox, guardAgainstKeyLengthMismatch, nestCompareConstraints, onMissingMethod, retrieveQuery, setDefaultAttributes, setParent, setRelated, setRelationMethodName, setRelationName, setReturnDefaultEntity, setWirebox, tap, unique, withDefault
     
    Methods inherited from class lucee.Component
    None

    Method Detail

    getResults

    public array<BaseEntity> getResults()

    Returns the result of the relationship.

    Returns:
    [quick.models.BaseEntity]

    initRelation

    public array<BaseEntity> initRelation(array entities, string relation)

    Initializes the relation to the null value for each entity in an array.

    Parameters:
    entities - The entities to initialize the relation.
    relation - The name of the relation to initialize.
    Returns:
    [quick.models.BaseEntity]

    match

    public array<BaseEntity> match(array entities, array results, string relation)

    Matches the array of entity results to an array of entities for a relation. Any matched records are populated into the matched entity's relation.

    Parameters:
    entities - The entities being eager loaded.
    results - The relationship results.
    relation - The relation name being loaded.
    Returns:
    [quick.models.BaseEntity]