You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
Deno already supports using and await using syntax with some APIs
Describe the solution you'd like
Instead of this:
{constclient=awaitpgPool.connect();try{// ... await some work}finally{client.release()}}
I wish write this:
{
using client=awaitpgPool.connect();// ... await some work}// client is released automatically
In addition, second step
Similar syntax can be used for transactions too, for example:
{
using client=awaitpgPool.connect();await using transaction=awaitclient.begin();awaittransaction.queryArray(...);awaittransaction.commit();// otherwise it will rollback}// - automatically rollback transaction if not commited and// report, that transaction was not properly closed (either commited or rolled back)// - release client
Advanced example:
{
using client=awaitpgPool.connect();try{await using transaction=awaitclient.begin();awaittransaction.queryArray(...);if(somethingBadHappened){awaittransaction.rollback();}awaittransaction.commit();}// automatically rollback transaction if not commited and// report, that transaction was not properly closed (either commited or rolled back)catch(error){// transaction is rolled backconsole.log(error);}}// release client
The text was updated successfully, but these errors were encountered:
Is your feature request related to a problem? Please describe.
Deno already supports
using
andawait using
syntax with some APIsDescribe the solution you'd like
Instead of this:
I wish write this:
In addition, second step
Similar syntax can be used for transactions too, for example:
Advanced example:
The text was updated successfully, but these errors were encountered: