Options
All
  • Public
  • Public/Protected
  • All
Menu

Class FromMeta

A helper class for keeping metadata about tables and columns used in a From instance.

Hierarchy

  • FromMeta

Index

Constructors

constructor

Properties

availableCols

availableCols: Map<string, FromColumnMeta> = new Map()

A map from fully-qualified property name to FromColumnMeta. These are the columns that are available for selecting, performing conditions on, or ordering by.

columnLookup

columnLookup: ColumnLookup = new ColumnLookup()

Lookup functionality between fully-qualified property names and fully-qualified column names. Users operate on Column-decorated properties, but ultimately those properties need to be mapped to fully-qualified column names when querying.

mapHierarchy

mapHierarchy: Map<string, Set<string>> = new Map()

Holds the mapping (RelationshipMetadata.mapTo) hierarchy. The map uses the parent alias as the key and a Set of mapping names (mapTo) as the values. The same mapping can be used multiple times, but each mapping must be unique to a parent. For example, it's valid for a person to have a "photo" and a building to have a "photo," but there cannot be two "photo" properties at same level (e.g. under person).

paramList

paramList: ParameterList = new ParameterList()

Stores all the parameters for the query. The parameters are used for WHERE and ON conditions.

tableMetas

tableMetas: Map<string, FromTableMeta> = new Map()

A map from table alias to FromTableMeta objects.

Methods

addTable

  • addTable(Entity: TableType, alias: string, parentAlias?: string, property?: string, joinType?: JoinType, cond?: object, params?: ParameterType): this
  • Add a table to the list and make all the columns in the table "available" for use in a select, condition, or order clause.

    Parameters

    • Entity: TableType

      Constructor of the Table-decorated class.

    • alias: string

      Alias of the table.

    • Default value parentAlias: string = null

      Alias of the parent table.

    • Default value property: string = null

      Property in the parent Entity to which children (this Entity) will be mapped.

    • Default value joinType: JoinType = null

      How this table was joined to from the parent.

    • Default value cond: object = null

      A join condition object for the two tables, or a where condition object for the parent table.

    • Default value params: ParameterType = null

      Any parameters used in the condition.

    Returns this

compileCondition

  • compileCondition(cond: object): string
  • Helper method to compile a condition. The compilation process ensures that each parameter in the condition has a replacement in the parameter list, and that each fully-qualified property in the condition is available (that is, belongs to one of the tables used in the From). Also, a ColumnLookup is supplied so that fully-qualified property names can be mapped to the associated column names.

    Parameters

    • cond: object

    Returns string

getFromColumnMeta

getFromColumnMetaByProp

getFromTableMeta

getFromTableMetaByAlias

getTableMetadataByAlias

isColumnAvailable

  • isColumnAvailable(fqProp: string): boolean
  • Check if the column is available (for selecting, for a condition, or for an order by clause).

    Parameters

    • fqProp: string

      The fully-qualified property name to look for.

    Returns boolean

setCondition

  • setCondition(alias: string, cond: object, params?: ParameterType): this
  • Set the condition object on one of the FromTableMeta objects and compile it.

    Parameters

    • alias: string

      Alias of the table to which the condition will be added.

    • cond: object

      The condition object to add and compile.

    • Default value params: ParameterType = null

      Any parameters in the cond object.

    Returns this

Generated using TypeDoc