Skip to content

DAO ORM Configuration

shturec edited this page Feb 27, 2017 · 12 revisions

version 1.0

status beta

dbName String

mandatory

properties Array[property]

mandatory

property Object

  • name String

    /mandatory/ The name of the entity property

  • dbName String

    /mandatory/ The name of the database record column corresponding to this entity property

  • type String

    /mandatory/ A valid type supported by the Database enterprise API. Note that it's the application type, not the SQL type , i.e. 'String', 'Long', 'Int' etc.

  • id Boolean

    /optional/ true if this property is identity field (primary key of the data record), false otherwise.

    Default: false

  • required Boolean

    /optional/ true if this property can be undefined (null in db record terms), false otherwise.

    Default: false

  • unique Boolean

    /optional/ true if this property value must be unique in the table, false otherwise. Insert for entity with property with constraint unique will fail if there is already another entity whose property has the same value.

    Default: false

  • size integer

    /optional/ if the type implies size (such as the character types) it can be provided with this property. The concrete dialect will choose the appropriate SQL character type for the size that you specify. The default size if none is specified with this property varies by dialects.

  • value Function(dbValue)

    /optional/ A transformation function that performs custom conversion from the data record field value to javacript value. Must return a valid JavaScript value for this property type. Useful e.g. for persisting dates as type long and still provisioning them as dates in the entity application model. Parameters:

    • dbValue Object

      The value of this property in the data record JSON object to transform to entity JSON value.

    • dataRecordEntity Object

      The data record JSON object that is being transformed to entity JSON.

    Returns: The transformed JSON entity value for this property.

    Default: The default transformation converts database record nulls to undefined in the resulting JSON object.

  • dbValue Function(value)

    /optional/ A transformation function that performs custom conversion from the entity property value to the corresponding data record field value. Must return a valid database value for this property type. Useful e.g. for persisting dates as type long and still provisioning them as dates in the entity application model. Parameters:

    • value Object

      The value of this property in the entity JSON object to transform to data record value.

    • entity Object

      The entity JSON object that is being transformed to data record JSON.

    Returns: The transformed data record JSON value for this property.

    Default: The default transformation converts JSON object undefined properties to null values in the resulting javascript data record object.

  • allowedOps Array of String

    /optional/ The operations allowed to consider this property. Valid strings are insert and update. For example, allowedOps: ['insert'] means that on insert of an entity this property can be assigned value and then becomes immutable, i.e. a subsequent update on this entity will not attempt to modify the property even a value has been provided.

    Default: undefined

associationSets Array[association]

optional

association Object

  • name String

    /mandatory/ An identifier for this association definition. The ORM method getAssociation will lookup association definitions based on this attribute.

  • type String

    /mandatory/ This association multiplicity. One of one-to-many, one-to-one, many-to-many, many-to-one.

  • joinKey String

    /mandatory/ The name of the field in the related (target) entity dao configuration that is used to join this entity. The foreign key field in relational terms.

  • key String

    optional The field in this entity, on which related entities are joined. Normally, that would be the primary key of the data record but not necessarily as any other unique, non-null field would do. For the latter cases, use key to specify that field.

    Default: The primary key field in this entity.

  • targetDao Function

    /mandatory/ A factory function for the relate (target)d entity DAO instances.

  • joinDao Function

    /mandatory for 'many-to-many' association type/ A factory function for the join entity (table) dao. Valid for many-to-many association type only.

    Note The joinDao must feature a listJoins function with single parameter settings of type object. The function will be invoked to transitively list the target related entities. The settings parameter object will feature:

    • sourceDao DAO object : This dao object
    • joinDao Object : The dao object on which the listJoins function is invoked
    • targetDao DAO Object : The dao object whose record we want to refer to as target ultimately
  • defaults Object

    optional Provides the arguments for the list function used to retrieve the many entities with their dao. By default no arguments are provided. This property will be ignored for all types of associations but one-to-many.

Clone this wiki locally