@@ -47,40 +47,40 @@ void describe('Pongo collection', () => {
4747 } ;
4848
4949 void describe ( 'Pool' , ( ) => {
50- // void it('connects using pool', async () => {
51- // const pool = new pg.Pool({ connectionString });
52-
53- // try {
54- // await insertDocumentUsingPongo(pool);
55- // } catch (error) {
56- // console.log(error);
57- // } finally {
58- // await pool.end();
59- // }
60- // });
61-
62- // void it('connects using connected pool client', async () => {
63- // const pool = new pg.Pool({ connectionString });
64- // const poolClient = await pool.connect();
65-
66- // try {
67- // await insertDocumentUsingPongo(poolClient);
68- // } finally {
69- // poolClient.release();
70- // await pool.end();
71- // }
72- // });
73-
74- // void it('connects using connected client', async () => {
75- // const client = new pg.Client({ connectionString });
76- // await client.connect();
77-
78- // try {
79- // await insertDocumentUsingPongo(client);
80- // } finally {
81- // await client.end();
82- // }
83- // });
50+ void it ( 'connects using pool' , async ( ) => {
51+ const pool = new pg . Pool ( { connectionString } ) ;
52+
53+ try {
54+ await insertDocumentUsingPongo ( pool ) ;
55+ } catch ( error ) {
56+ console . log ( error ) ;
57+ } finally {
58+ await pool . end ( ) ;
59+ }
60+ } ) ;
61+
62+ void it ( 'connects using connected pool client' , async ( ) => {
63+ const pool = new pg . Pool ( { connectionString } ) ;
64+ const poolClient = await pool . connect ( ) ;
65+
66+ try {
67+ await insertDocumentUsingPongo ( poolClient ) ;
68+ } finally {
69+ poolClient . release ( ) ;
70+ await pool . end ( ) ;
71+ }
72+ } ) ;
73+
74+ void it ( 'connects using connected client' , async ( ) => {
75+ const client = new pg . Client ( { connectionString } ) ;
76+ await client . connect ( ) ;
77+
78+ try {
79+ await insertDocumentUsingPongo ( client ) ;
80+ } finally {
81+ await client . end ( ) ;
82+ }
83+ } ) ;
8484
8585 void it ( 'connects using existing connection' , async ( ) => {
8686 const pool = dumbo ( { connectionString } ) ;
@@ -101,20 +101,20 @@ void describe('Pongo collection', () => {
101101 }
102102 } ) ;
103103
104- // void it('connects using existing connection from transaction', async () => {
105- // const pool = dumbo({ connectionString });
106-
107- // try {
108- // await pool.withTransaction(async ({ connection }) => {
109- // const pongo = pongoClient(connectionString, { connection });
110-
111- // const users = pongo.db().collection<User>('connections');
112- // await users.insertOne({ name: randomUUID() });
113- // await users.insertOne({ name: randomUUID() });
114- // });
115- // } finally {
116- // await pool.close();
117- // }
118- // });
104+ void it ( 'connects using existing connection from transaction' , async ( ) => {
105+ const pool = dumbo ( { connectionString } ) ;
106+
107+ try {
108+ await pool . withTransaction ( async ( { connection } ) => {
109+ const pongo = pongoClient ( connectionString , { connection } ) ;
110+
111+ const users = pongo . db ( ) . collection < User > ( 'connections' ) ;
112+ await users . insertOne ( { name : randomUUID ( ) } ) ;
113+ await users . insertOne ( { name : randomUUID ( ) } ) ;
114+ } ) ;
115+ } finally {
116+ await pool . close ( ) ;
117+ }
118+ } ) ;
119119 } ) ;
120120} ) ;
0 commit comments