Skip to content

Commit

Permalink
docs: Some sentence updated for datasource doc (typeorm#11182)
Browse files Browse the repository at this point in the history
  • Loading branch information
albasyir authored Dec 12, 2024
1 parent 1465773 commit 755191e
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions docs/data-source.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@

Your interaction with the database is only possible once you setup a `DataSource`.
TypeORM's `DataSource` holds your database connection settings and
establishes initial database connection or connection pool depending on the RDBMS you use.
establishes the initial database connection or connection pool depending on the RDBMS you use.

In order to establish initial connection / connection pool you must call `initialize` method of your `DataSource` instance.
To establish the initial connection/connection pool, you must call the `initialize` method of your `DataSource` instance.

Disconnection (closing all connections in the pool) is made when `destroy` method is called.
Disconnection (closing all connections in the pool) occurs when the `destroy` method is called.

Generally, you call `initialize` method of the `DataSource` instance on application bootstrap,
and `destroy` it after you completely finished working with the database.
Generally, you call the `initialize` method of the `DataSource` instance on the application bootstrap,
and `destroy` it after you finished working with the database.
In practice, if you are building a backend for your site and your backend server always stays running -
you never `destroy` a DataSource.

Expand Down Expand Up @@ -45,11 +45,10 @@ AppDataSource.initialize()
})
```

It's a good idea to make `AppDataSource` globally available by `export`-ing it, since you'll
use this instance across your application.
It's a good idea to make `AppDataSource` globally available by `export`-ing it since you'll use this instance across your application.

`DataSource` accepts `DataSourceOptions` and those options vary depend on database `type` you use.
For different database types there are different options you can specify.
`DataSource` accepts `DataSourceOptions` and those options vary depending on the database `type` you use.
For different database types, there are different options you can specify.

You can define as many data sources as you need in your application, for example:

Expand Down Expand Up @@ -97,6 +96,6 @@ export class UserController {
}
```

Using `DataSource` instance you can execute database operations with your entities,
Using the `DataSource` instance you can execute database operations with your entities,
particularly using `.manager` and `.getRepository()` properties.
For more information about them see [Entity Manager and Repository](working-with-entity-manager.md) documentation.

0 comments on commit 755191e

Please sign in to comment.