You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
13 lines
394 B
13 lines
394 B
import {QueryResult} from "pg";
|
|
|
|
export function singleQueryResult<T>(result: QueryResult<[T]>): T | undefined {
|
|
return singleColumnQueryResult(result)[0]
|
|
}
|
|
|
|
export function singleColumnQueryResult<T>(result: QueryResult<[T]>): T[] {
|
|
return result.rows.map(([item]) => item)
|
|
}
|
|
|
|
export function singleRowQueryResult<T>(result: QueryResult<T>): T | undefined {
|
|
return result.rows[0]
|
|
} |