.fetchValueXxx()
ignores all previous calls to.map()
.fetchValueXxx()
may only be called if theSELECT
clause is of length one and a column or aliased expression is selected.
The .fetchValueXxx()
methods fetch a single row, at most.
.fetchValue()
.fetchValueOr()
.fetchValueOrUndefined()
Convenience method for,
const row : { myColumn : bigint } = await tsql
.from(myTable)
.select(columns => [columns.myColumn])
.fetchOne(connection);
const bigintValue : bigint = row.myColumn;
Usage,
const bigintValue : bigint = await tsql
.from(myTable)
.select(columns => [columns.myColumn])
.fetchValue(connection);
Convenience method for,
const row : { myColumn : bigint }|string = await tsql
.from(myTable)
.select(columns => [columns.myColumn])
.fetchOneOr(connection, "whoops, no value");
const bigintOrStringValue : bigint|string = (
typeof row == "string" ?
row :
row.myColumn
);
Usage,
const bigintOrStringValue : bigint|string = await tsql
.from(myTable)
.select(columns => [columns.myColumn])
.fetchValueOr(connection, "whoops, no value");
Convenience method for .fetchValueOr(connection, undefined)
.
.fetchValue()
actually returns a value of type ExecutionUtil.FetchValuePromise<>
It is essentially the same as Promise<>
, with two extra methods,
-
.or(defaultValue)
Behaves the same as
.fetchValueOr()
myQuery .fetchValue(connection) .or(1337) .then((value) => { if (value == 1337) { //No value was fetched... Or the value fetched is 1337 } else { //A value was fetched } });
-
.orUndefined()
Behaves the same as
.fetchValueOrUndefined()
myQuery .fetchValue(connection) .orUndefined() .then((value) => { if (value == undefined) { //No value was fetched } else { //A value was fetched } });