Function: safeGetRowProperty()
safeGetRowProperty<
T
>(row
:UnknownRecord
,property
:string
,defaultValue
:T
):T
Defined in: shared/types/database.ts:358
Safely retrieves a property value from a database row object.
Type Parametersโ
Tโ
T
The expected type of the property value.
Parametersโ
rowโ
UnknownRecord
The database row object.
propertyโ
string
The property name to access.
defaultValueโ
T
The value to return if the property is missing or undefined.
Returnsโ
T
The property value if present; otherwise, the default value.
Remarksโ
Returns the value of the specified property if it exists and is not undefined; otherwise, returns the provided default value.
Exampleโ
const name = safeGetRowProperty(row, "name", "Unknown");