mirror of
https://github.com/chenasraf/DefinitelyTyped.git
synced 2026-05-18 01:49:01 +00:00
🤖 Merge PR #65348 [pg] Add missing parameter to BindConfig by @iamkhush
* add valuemapper to BindConfig * fix lint errors * add test for bindconfig * add pg version * update pg-types and package version * Revert "update pg-types and package version" This reverts commit df6aa8755a5f8574a9289d737a2eefdd003e1ef6. * fix comment * revert another change
This commit is contained in:
3
types/pg/index.d.ts
vendored
3
types/pg/index.d.ts
vendored
@@ -118,11 +118,14 @@ export interface QueryParse {
|
||||
types: string[];
|
||||
}
|
||||
|
||||
type ValueMapper = (param: any, index: number) => any;
|
||||
|
||||
export interface BindConfig {
|
||||
portal?: string | undefined;
|
||||
statement?: string | undefined;
|
||||
binary?: string | undefined;
|
||||
values?: Array<Buffer | null | undefined | string> | undefined;
|
||||
valueMapper?: ValueMapper | undefined;
|
||||
}
|
||||
|
||||
export interface ExecuteConfig {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { connect } from 'net';
|
||||
import { types, Client, CustomTypesConfig, QueryArrayConfig, Pool, DatabaseError } from 'pg';
|
||||
import { types, Client, CustomTypesConfig, QueryArrayConfig, Pool, DatabaseError, Connection } from 'pg';
|
||||
import TypeOverrides = require('pg/lib/type-overrides');
|
||||
import { NoticeMessage } from 'pg-protocol/dist/messages';
|
||||
|
||||
@@ -344,3 +344,13 @@ const dynamicPasswordAsync = new Client({
|
||||
password: async () => 'sync-secret',
|
||||
});
|
||||
dynamicPasswordAsync.connect();
|
||||
|
||||
const bindConfig = {
|
||||
statement: 'Select 1 from foo where bar = $1',
|
||||
binary: 'false',
|
||||
values: ['xyz'],
|
||||
valueMapper: (param: any, index: number) => ([param, index])
|
||||
};
|
||||
|
||||
const con = new Connection();
|
||||
con.bind(bindConfig, true);
|
||||
|
||||
Reference in New Issue
Block a user