Extends
Members
attrs
static
Attributes defined in metadata. This property not exist in real life and added just for help
entity: UBEntity
Reference to entity metadata
Methods
addNew(ctx)
api
Create record with filled default values and return it to caller.
Newly created record is not inserted to database. For inserting record to the database insert
method should be called
Arguments:
-
ctx
(ubMethodParams)
- Mixes In:
-
mStorage.addNew   
delete(ctx)
api
Delete data
Arguments:
-
ctx
(ubMethodParams)
Properties
-
mParams.execParams.ID
(number)
 element ID to be deleted
- Mixes In:
-
mStorage.delete   
insert(ctx)
api
Insert new row to the entity.
Arguments:
-
ctx
(ubMethodParams)
Properties
- Mixes In:
-
mStorage.insert   
select(ctx)
api
Read entity data
Arguments:
-
ctx
(ubMethodParams)
Properties
-
mParams
(UBQL)
 ORM query in UBQL format
- Mixes In:
-
mStorage.select   
update(ctx)
api
Update data
Arguments:
-
ctx
(ubMethodParams)
Properties
- Mixes In:
-
mStorage.update   
generateAutoIncrementalCode(ctx, forAttributeopt)
Generate auto incremental code for specified entity attribute in case
attribute value in execParams is empty or equal to attribute default value,
specified in meta file.
Will create a numcounter with code === entity.name and 1 as initial value.
Result value will be left padded by '0' to the length specified in ubs_settings
To be used in insert:before
handler as
Arguments:
-
ctx
(ubMethodParams)
Properties
-
[forAttribute='code']
(string)
 Code of attribute for number generation
Example
const me = cdn_profession
me.on('insert:before', generateAutoIncrementalCode)
function generateAutoIncrementalCode (ctx) {
ubs_numcounter.generateAutoIncrementalCode(ctx, 'code')
}
//or even simple if attribute name is `code`
me.on('insert:before', ubs_numcounter.generateAutoIncrementalCode)
getRegnum(regKeyValue, startNumopt, skipReservedNumberopt) → Number
Return counter number by mask
Arguments:
-
regKeyValue
(String)
 Registration key mask
-
[startNum]
(Number)
 The starting counter value in case mask not exists
-
[skipReservedNumber=false]
(Boolean)
 When "true" skip loading number from reserve and calculate new number by mask
getRegnumCounter(ctxt)
api
Get counter value by registration key
Arguments:
-
ctxt
(ubMethodParams)
Properties
addNew(ctx) api
Create record with filled default values and return it to caller.
Newly created record is not inserted to database. For inserting record to the database
insert
method should be called
Arguments:
-
ctx
(ubMethodParams)
- Mixes In:
- mStorage.addNew   
delete(ctx) api
Delete data
Arguments:
-
ctx
(ubMethodParams)
Properties
-
mParams.execParams.ID
(number)
 element ID to be deleted
-
- Mixes In:
- mStorage.delete   
insert(ctx) api
Insert new row to the entity.
Arguments:
-
ctx
(ubMethodParams)
Properties
- Mixes In:
- mStorage.insert   
select(ctx) api
Read entity data
Arguments:
-
ctx
(ubMethodParams)
Properties
-
mParams
(UBQL)
 ORM query in UBQL format
-
- Mixes In:
- mStorage.select   
update(ctx) api
Update data
Arguments:
-
ctx
(ubMethodParams)
Properties
- Mixes In:
- mStorage.update   
generateAutoIncrementalCode(ctx, forAttributeopt)
Generate auto incremental code for specified entity attribute in case
attribute value in execParams is empty or equal to attribute default value,
specified in meta file.
Will create a numcounter with code === entity.name and 1 as initial value.
Result value will be left padded by '0' to the length specified in ubs_settings
To be used in insert:before
handler as
Arguments:
-
ctx
(ubMethodParams)
Properties
-
[forAttribute='code']
(string)
 Code of attribute for number generation
Example
const me = cdn_profession
me.on('insert:before', generateAutoIncrementalCode)
function generateAutoIncrementalCode (ctx) {
ubs_numcounter.generateAutoIncrementalCode(ctx, 'code')
}
//or even simple if attribute name is `code`
me.on('insert:before', ubs_numcounter.generateAutoIncrementalCode)
getRegnum(regKeyValue, startNumopt, skipReservedNumberopt) → Number
Return counter number by mask
Arguments:
-
regKeyValue
(String)
 Registration key mask -
[startNum]
(Number)
 The starting counter value in case mask not exists -
[skipReservedNumber=false]
(Boolean)
 When "true" skip loading number from reserve and calculate new number by mask
getRegnumCounter(ctxt) api
Get counter value by registration key
Arguments:
-
ctxt
(ubMethodParams)
Properties