-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathindex.ts
56 lines (53 loc) · 1.37 KB
/
index.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
48
49
50
51
52
53
54
55
56
import { ClientImpl, type ConnectionInfo } from './client.js';
export {
SSLMode,
type ClientNotice,
type Configuration,
type DataTypeError,
type EventListener,
type EventMap,
type Notification,
type PreparedStatement,
type SSL,
} from './client.js';
import type { Configuration } from './client.js';
export {
DataFormat,
DataType,
type Point,
type ValueTypeReader,
} from './types.js';
export type { Query, QueryOptions } from './query.js';
export type {
Result,
ResultIterator,
ResultRecord,
ResultRow,
} from './result.js';
export type { Environment } from './defaults.js';
export type {
ClientConnectionDefaults,
ClientConnectionOptions,
DatabaseError,
ErrorLevel,
TransactionStatus,
} from './protocol.js';
interface _Client extends ClientImpl {}
/** A database client, encapsulating a single connection to the database.
*
* @interface
*/
export type Client = Omit<_Client, 'connect'> & ConnectionInfo;
/** Connect to the database.
*
* @remarks
* You must close the connection after use using {@link Client.end} to close
* open handles.
*
* @returns A database client, with an active connection.
*/
export async function connect(config: Configuration = {}): Promise<Client> {
const client = new ClientImpl(config);
const info = await client.connect();
return Object.assign(client, info);
}