Members
attributes: Object.<string, UBEntityAttribute>
Entity attributes collection
blobAttributes: Array.<UBEntityAttribute>
Slice of attributes with type Document
cacheType: UBDomain.EntityCacheTypes
readonly
Indicate how entity content is cached on the client side.
caption: string
Entity caption
code: string
readonly
connectionConfig: DBConnectionConfig
readonly
Reference to connection definition (for extended domain only)
connectionName: string
readonly
Data source connection name
dbExtensions: object
Optional dbExtensions (for extended domain info)
dbKeys: object
Optional dbKeys (for extended domain info)
description: string
Entity description
descriptionAttribute: string
Name of attribute witch used as a display value in lookup
documentation: string
Documentation
dsType: UBDomain.EntityDataSourceType
entityMethods: Object.<string, Number>
readonly
Entity methods, allowed for current logged-in user in format {method1: 1, method2: 1}. 1 mean method is allowed
Empty for server-side domain - use entity.haveAccessToMethod
to check method is accessible for user.
isFTSDataTable: boolean
This is a Full Text Search entity
isUnity: boolean
Indicate this entity is a UNITY for someone
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
mixins: Object.<string, UBEntityMixin>
Collection of entity mixins
modelName
readonly
Entity model name
name: string
readonly
Entity name
sqlAlias: string
readonly
Internal short alias
Methods
addMethod(methodName)
Add entity level method. Client can call such methods remotely. Also such methods are the subjects of ELS.
Property named methodName
with a type function
should be added to the entity namespace.
Such functions accept single parameter of type ubMethodParams
Don't add methods what do not called from client using {@UBEntity#addMethod}!
Warning: do not call UBEntity.addMethod from inside function or conditions.
This code evaluated during thread initialization and each thread must add method in the same manner.
Arguments:
-
methodName
(string)
Example
//consider entity with code `my_entity` exists. Inside my_entity.js file):
var me = my_entity;
me.entity.addMethod('externalMethod');
// @param {ubMethodParams} ctx <- here must be JSDoc comment format
me.externalMethod = function (ctx) {
let params = ctx.mParams
let a = params.a || 1
let b = params.b || 1
params.multiplyResult = a*b
}
// now from client side you can call
$App.connection.query({entity: 'my_entity', method: 'externalMethod', a: 10, b:20}).then(function(result){
console.log(' 10 * 20 = ', result.multiplyResult); // will put to log "10 * 20 = 200"
})
attr(attributeCode, simpleOnlyopt) → UBEntityAttribute
Get entity attribute by code. Return undefined
if attribute is not found
Arguments:
-
attributeCode
(string)
-
[simpleOnly=false]
(Boolean)
 If false
(default) - parse complex attributes like attr1.attr2.attr3
checkAttributeExist(attributeNames, contextMessage)
Checks entity has attribute(s) and throw error if not
Arguments:
checkMixin(mixinCode)
Checks if entity has mixin. Throw if mixin dose not exist or not enabled
Arguments:
-
mixinCode
(string)
eachAttribute(callBack)
Iterates over entity attributes.
The iteratee is invoked with three arguments: (UBEntityAttribute, attributeName, UBEntityAttributes)
Arguments:
-
callBack
(entityAttributesIteratorCallback)
filterAttribute(predicate) → Array.<UBEntityAttribute>
Filters attributes by properties
Arguments:
Example
// return all attributes where property dataType equal Document
domain.get('uba_user').filterAttribute({dataType: 'Document'});
getAttribute(attributeCode) → UBEntityAttribute
Get entity attribute by code. Throw error if attribute is not found.
Arguments:
-
attributeCode
getAttributeNames(predicateopt) → Array.<string>
Returns array of entity attribute`s names
Arguments:
-
[predicate]
(Object|function)
 See UBEntity.filterAttribute. If empty - will return all names
getConvertRules(fieldList) → Array.<{index: number, convertFn: function()}>
Return array of conversion rules for raw server response data
Arguments:
-
fieldList
(Array.<string>)
getDescriptionAttribute() → string
Returns description attribute name (descriptionAttribute
metadata property)
If descriptionAttribute
is empty - fallback to attribute with code caption
getEntityAttribute(attributeName, depthopt) → UBEntityAttribute
Returns entity attribute. Understand complex attributes like firmID.firmType.code
Arguments:
-
attributeName
(string)
-
[depth=0]
(number)
 Current recursion depth
0
means last attribute in chain (code from above)
-1
- before last (firmType from above)
>0
- first (firmID from above)
getEntityAttributeInfo(attributeName, depthopt) → Object|undefined
Returns information about attribute and attribute entity. Understand complex attributes like firmID.firmType.code
Arguments:
-
attributeName
(string)
-
[depth=0]
(number)
 If 0 - last, -1 - before last, > 0 - first. Default 0.
0
means last attribute in chain (code from above)
-1
- before last (firmType from above)
>0
- first (firmID from above)
getEntityCaption() → string
Return an entity caption to display on UI
getEntityDescription() → string
Return entity description
getEntityRequirements(fieldListopt) → Array.<string>
For each attribute of type Entity
from fieldList
add entity code to result (duplicates are removed)
Arguments:
-
[fieldList]
(Array.<string>)
 If empty - all entity attributes will be used
hasMixin(mixinCode) → Boolean
Checks if entity has enabled mixin with specified code.
Arguments:
-
mixinCode
(string)
haveAccessToAnyMethods(methodsCodes) → boolean
Checks if current user has access to at last one of specified methods
Arguments:
-
methodsCodes
(Array.<string>)
haveAccessToMethod(methodCode) → Boolean
Checks if current user has access to specified entity method
Arguments:
-
methodCode
(string)
haveAccessToMethods(methods) → Boolean
Checks if current user has access to ALL of the specified methods
Arguments:
-
methods
(Array.<string>)
 Method names
mixin(mixinCode) → UBEntityMixin
Get entity mixin by code. Returns undefined
if mixin is not found
Arguments:
-
mixinCode
(string)
Document
entity.haveAccessToMethod
to check method is accessible for user.
addMethod(methodName)
Add entity level method. Client can call such methods remotely. Also such methods are the subjects of ELS.
Property named methodName
with a type function
should be added to the entity namespace.
Such functions accept single parameter of type ubMethodParams
Don't add methods what do not called from client using {@UBEntity#addMethod}!
Warning: do not call UBEntity.addMethod from inside function or conditions. This code evaluated during thread initialization and each thread must add method in the same manner.
Arguments:
-
methodName
(string)
Example
//consider entity with code `my_entity` exists. Inside my_entity.js file):
var me = my_entity;
me.entity.addMethod('externalMethod');
// @param {ubMethodParams} ctx <- here must be JSDoc comment format
me.externalMethod = function (ctx) {
let params = ctx.mParams
let a = params.a || 1
let b = params.b || 1
params.multiplyResult = a*b
}
// now from client side you can call
$App.connection.query({entity: 'my_entity', method: 'externalMethod', a: 10, b:20}).then(function(result){
console.log(' 10 * 20 = ', result.multiplyResult); // will put to log "10 * 20 = 200"
})
attr(attributeCode, simpleOnlyopt) → UBEntityAttribute
Get entity attribute by code. Return
undefined
if attribute is not found
Arguments:
-
attributeCode
(string)
-
[simpleOnly=false]
(Boolean)
 Iffalse
(default) - parse complex attributes likeattr1.attr2.attr3
checkAttributeExist(attributeNames, contextMessage)
Checks entity has attribute(s) and throw error if not
Arguments:
checkMixin(mixinCode)
Checks if entity has mixin. Throw if mixin dose not exist or not enabled
Arguments:
-
mixinCode
(string)
eachAttribute(callBack)
Iterates over entity attributes.
The iteratee is invoked with three arguments: (UBEntityAttribute, attributeName, UBEntityAttributes)
Arguments:
-
callBack
(entityAttributesIteratorCallback)
filterAttribute(predicate) → Array.<UBEntityAttribute>
Filters attributes by properties
Arguments:
Example
// return all attributes where property dataType equal Document
domain.get('uba_user').filterAttribute({dataType: 'Document'});
getAttribute(attributeCode) → UBEntityAttribute
Get entity attribute by code. Throw error if attribute is not found.
Arguments:
-
attributeCode
getAttributeNames(predicateopt) → Array.<string>
Returns array of entity attribute`s names
Arguments:
-
[predicate]
(Object|function)
 See UBEntity.filterAttribute. If empty - will return all names
getConvertRules(fieldList) → Array.<{index: number, convertFn: function()}>
Return array of conversion rules for raw server response data
Arguments:
-
fieldList
(Array.<string>)
getDescriptionAttribute() → string
Returns description attribute name (
descriptionAttribute
metadata property)
If descriptionAttribute
is empty - fallback to attribute with code caption
getEntityAttribute(attributeName, depthopt) → UBEntityAttribute
Returns entity attribute. Understand complex attributes like
firmID.firmType.code
Arguments:
-
attributeName
(string)
-
[depth=0]
(number)
 Current recursion depth
0
means last attribute in chain (code from above)-1
- before last (firmType from above)>0
- first (firmID from above)
getEntityAttributeInfo(attributeName, depthopt) → Object|undefined
Returns information about attribute and attribute entity. Understand complex attributes like
firmID.firmType.code
Arguments:
-
attributeName
(string)
-
[depth=0]
(number)
 If 0 - last, -1 - before last, > 0 - first. Default 0.
0
means last attribute in chain (code from above)-1
- before last (firmType from above)>0
- first (firmID from above)
getEntityCaption() → string
Return an entity caption to display on UI
getEntityDescription() → string
Return entity description
getEntityRequirements(fieldListopt) → Array.<string>
For each attribute of type
Entity
from fieldList
add entity code to result (duplicates are removed)
Arguments:
-
[fieldList]
(Array.<string>)
 If empty - all entity attributes will be used
hasMixin(mixinCode) → Boolean
Checks if entity has enabled mixin with specified code.
Arguments:
-
mixinCode
(string)
haveAccessToAnyMethods(methodsCodes) → boolean
Checks if current user has access to at last one of specified methods
Arguments:
-
methodsCodes
(Array.<string>)
haveAccessToMethod(methodCode) → Boolean
Checks if current user has access to specified entity method
Arguments:
-
methodCode
(string)
haveAccessToMethods(methods) → Boolean
Checks if current user has access to ALL of the specified methods
Arguments:
-
methods
(Array.<string>)
 Method names
mixin(mixinCode) → UBEntityMixin
Get entity mixin by code. Returns
undefined
if mixin is not found
Arguments:
-
mixinCode
(string)