Documentation / @andrew_l/mongo-transaction / useMongoSession
Function: useMongoSession() ​
useMongoSession():
null
|ClientSession
Returns the current transaction session if executed within withMongoTransaction()
otherwise returns null
Returns ​
null
| ClientSession
Example ​
ts
async function createAlert() {
const session = useMongoSession();
await db.alerts.insertOne(
{ title: 'Order Created' },
{ session: session ?? undefined }
);
}