forked from fastify/fastify-postgres
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.d.ts
47 lines (38 loc) · 994 Bytes
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { FastifyPluginCallback } from 'fastify';
import * as Pg from 'pg';
declare function transact<TResult>(
fn: (client: Pg.PoolClient) => Promise<TResult>
): Promise<TResult>;
declare function transact<TResult>(
fn: (client: Pg.PoolClient) => Promise<TResult>,
cb: (error: Error | null, result?: TResult) => void
): void;
type PostgresDb = {
pool: Pg.Pool;
Client: Pg.Client;
query: Pg.Pool['query'];
connect: Pg.Pool['connect'];
transact: typeof transact;
};
type PostgresPluginOptions = {
/**
* Custom pg
*/
pg?: typeof Pg;
/**
* Use pg-native
*/
native?: boolean;
/**
* Instance name of fastify-postgres
*/
name?: string;
} & Pg.PoolConfig;
declare const fastifyPostgres: FastifyPluginCallback<PostgresPluginOptions>;
declare module 'fastify' {
export interface FastifyInstance {
pg: PostgresDb & Record<string, PostgresDb>;
}
}
export { fastifyPostgres, PostgresDb, PostgresPluginOptions };
export default fastifyPostgres;