How can I write SELECT * as QBSelect (QueryBuilder)?
I found out, that I can use query.result.add( query.columns.index ) as SELECT index, but is seems not to work like this: query.result.add( query.columns[ ‘*’ ] ).
How can I get all columns with the QueryBuilder?
Hi Sebastian,
It seems the QueryBuilder doesn’t support the SELECT * syntax. You need to name every column you want to query which is a pain.
You could file a feature request for this.
In the mean time you could use the following method to get all columns:
/**
* @param {QBSelect} _oSelect
*/
function getAllColumns(_oSelect) {
/** @type {Array<String>} */
var _aNames = _oSelect.columns['allnames'];
_aNames.map(function(_sName) {
_oSelect.result.add(_oSelect.getColumn(_sName));
});
// no need to return anything since it was passed as a reference
}
Then you just call it like so:
getAllColumns(query);
Hope this helps.