UBEntity

@unitybase/base/UBDomain~ UBEntity

new UBEntity(entityInfo, entityMethods, i18n, entityCode, domain)

Arguments:
  1. entityInfo (Object)
  2. entityMethods (Object)
  3. i18n (Object)
  4. entityCode (String)
  5. domain (UBDomain)

Members

code: String readonly

modelName readonly

Entity model name

name: String readonly

Entity name

sqlAlias: String readonly

Internal short alias

connectionName: String readonly

Data source connection name

isFTSDataTable: boolean

This is a Full Text Search entity

connectionConfig: DBConnectionConfig readonly

Reference to connection definition (for extended domain only)

mapping: UBEntityMapping readonly

Optional mapping of entity to physical data (for extended domain info only). Calculated from a entity mapping collection in accordance with application connection configuration

dbKeys: Object

Optional dbKeys (for extended domain info)

dbExtensions: Object

Optional dbExtensions (for extended domain info)

attributes: Object.<string, UBEntityAttribute>

Entity attributes collection

mixins: Object.<String, UBEntityMixin>

Collection of entity mixins

entityMethods: Object.<String, Number> readonly

Entity methods, allowed for current logged-in user in format {method1: 1, method2: 1}. 1 mean method is allowed

caption: string

Entity caption

description: string

Entity description

documentation: string

Documentation

descriptionAttribute: string

Name of attribute witch used as a display value in lookup

cacheType: UBDomain.EntityCacheTypes readonly

Indicate how entity content is cached on the client side.

dsType: UBDomain.EntityDataSourceType

Methods

getEntityCaption()string

Return an entity caption to display on UI

attr(attributeCode, simpleopt)UBEntityAttribute

Get entity attribute by code. Return undefined if attribute does not found
Arguments:
  1. attributeCode (String)
  2. [simple] (Boolean)  Is do not complex attribute name. By default false.

getAttribute(attributeCode)UBEntityAttribute

Get entity attribute by code. Throw error if attribute does not found.
Arguments:
  1. attributeCode

eachAttribute(callBack)

Call callBack function for each attribute.
Arguments:
  1. callBack (function)

mixin(mixinCode)UBEntityMixin

Get entity mixin by code. Returns "undefined" if the mixin is not found
Arguments:
  1. mixinCode (String)

hasMixin(mixinCode)Boolean

Check the entity has mixin. Returns true if the mixin is exist and enabled
Arguments:
  1. mixinCode (String)

checkMixin(mixinCode)

Check the entity has mixin. Throw error if mixin dose not exist or not enabled
Arguments:
  1. mixinCode (String)

haveAccessToMethod(methodCode)Boolean

Check current user have access to specified entity method
Arguments:
  1. methodCode (String)

filterAttribute(config)Array

Filter attributes by properties
Arguments:
  1. config (Object|function)

haveAccessToAnyMethods(methods)boolean

Check current user have access to AT LAST one of specified methods
Arguments:
  1. methods (Array)

haveAccessToMethods(methods)Boolean

Check current user have access to ALL of specified methods
Arguments:
  1. methods (Array.<String>)  Method names

getConvertRules(fieldList) → Array.<{index: number, convertFn: function()}>

Return array of conversion rules for raw server response data
Arguments:
  1. fieldList (Array.<String>)

getDescriptionAttribute()String

Return description attribute name (descriptionAttribute metadata property) This property may be empty or valid(validation performed by server) If case property is empty - try to get attribute with code caption

getEntityAttributeInfo(attributeName, deepopt)Object

Return information about attribute and attribute entity. Understand complex attributes like firmID.firmType.code
Arguments:
  1. attributeName (String)
  2. [deep] (Number)  If 0 - last, -1 - before last, > 0 - root. Default 0.

getEntityAttribute(attributeName, deepopt)UBEntityAttribute

Return Entity attribute. Understand complex attributes like firmID.firmType.code
Arguments:
  1. attributeName (String)
  2. [deep] (Number)  If 0 - last, -1 - before last, > 0 - root. Default 0.

getAttributeNames(filteropt)

return attributes code list
Arguments:
  1. [filter] (Object|function)

getEntityRequirements(fieldListopt) → Array.<String>

Return requirements entity code list for field list
Arguments:
  1. [fieldList] (Array.<String>)  (optional)

checkAttributeExist(attributeName, contextMessage)

Check the entity contains attribute(s) and throw error if not contains
Arguments:
  1. attributeName (String|Array.<String>)
  2. contextMessage (String)

getEntityDescription()string

Return entity description.