Cols.each()
This article is about the each() function of the Cols object.
Cols.each()
Iterates the execution of a function over the matched columns.
Returns a UdbPromise object.
Like Rowset.each() and Rows.each(), this function settles all the calls before resolving, even if one or more of them are rejected.
Syntax
$.udb( *ds* ).cols( [columns] ).each( *function*( *index*, *column* ) )
.then( ( *result* ) => {
// success
});
$.udb( *ds* ).rows( [rowRef1], [rowRef2] ).cols( [columns] ).each( *function*( *index*, *column* ) )
.then( ( *result* ) => {
// success
});
$.udb( *ds* ).rowSet( *rowSet* ).rows( [rowRef1], [rowRef2] ).cols( [columns] ).each( *function*( *index*, *column* ) )
.then( ( *result* ) => {
// success
});
The required ds parameter is a data source selector.
The optional rowSet parameter is a rowset identifier. If the .rowSet() clause is omitted, then .rowSet('current') is assumed.
The optional rowRef1, rowRef2 are row selectors. If omitted, only the column meta data can be accessed.
The optional columns is a column selector. If omitted, all columns in scope are selected.
Function is the function that is to be called for each of the matched columns.
Index is the array index of the column for which the function is executed. This index is 0-based.
Column is a single-column Cols object wrapping the column itself. Effectively, column is the same object as returned to the function call as this.
The result passed to the .then() clause is an array with, for each matched column, an object describing whether that call was fulfilled or rejected (in the same shape as the standard Promise.allSettled() result).
Example
$.udb('EMP').rows('current').cols().each((index, col) => {
console.log(col.name());
});