Skip to content

Commit

Permalink
docs: update examples for "initializeTransactionalContext"
Browse files Browse the repository at this point in the history
  • Loading branch information
Aliheym committed Oct 23, 2023
1 parent 900c13c commit ba9f379
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ See [Changelog](#CHANGELOG.md)
- [It's a fork of typeorm-transactional-cls-hooked for new versions of TypeORM.](#its-a-fork-of-typeorm-transactional-cls-hooked-for-new-versions-of-typeorm)
- [Installation](#installation)
- [Initialization](#initialization)
- [Usage](#usage)
- [Using Transactional Decorator](#using-transactional-decorator)
- [Data Sources](#data-sources)
- [Transaction Propagation](#transaction-propagation)
Expand Down Expand Up @@ -57,9 +56,10 @@ yarn add typeorm reflect-metadata
In order to use it, you will first need to initialize the transactional context before your application is started

```typescript
import { initializeTransactionalContext } from 'typeorm-transactional';
import { initializeTransactionalContext, StorageDriver } from 'typeorm-transactional';

initializeTransactionalContext()
initializeTransactionalContext({ storageDriver: StorageDriver.AUTO });
```
...
app = express()
...
Expand All @@ -81,15 +81,15 @@ import { DataSource } from 'typeorm';
import { initializeTransactionalContext, addTransactionalDataSource, StorageDriver } from 'typeorm-transactional';
...
const dataSource = new DataSource({
type: 'postgres',
type: 'postgres',
host: 'localhost',
port: 5435,
username: 'postgres',
password: 'postgres'
});
...
initializeTransactionalContext({ storageDriver: StorageDriver.ASYNC_LOCAL_STORAGE });
initializeTransactionalContext({ storageDriver: StorageDriver.AUTO });
addTransactionalDataSource(dataSource);
...
Expand All @@ -101,12 +101,12 @@ Example for `Nest.js`:
// main.ts

import { NestFactory } from '@nestjs/core';
import { initializeTransactionalContext } from 'typeorm-transactional';
import { initializeTransactionalContext, StorageDriver } from 'typeorm-transactional';

import { AppModule } from './app';

const bootstrap = async () => {
initializeTransactionalContext();
initializeTransactionalContext({ storageDriver: StorageDriver.AUTO });

const app = await NestFactory.create(AppModule, {
abortOnError: true,
Expand Down

0 comments on commit ba9f379

Please sign in to comment.