|
2 | 2 |
|
3 | 3 | ##### This chapter applies only to TypeScript
|
4 | 4 |
|
5 |
| -> **Warning** In this article, you'll learn how to create a `DatabaseModule` based on the **Sequelize** package from scratch using custom components. As a consequence, this technique contains a lot of overhead that you can avoid by using the dedicated, out-of-the-box `@nestjs/sequelize` package. To learn more, see [here](/techniques/database#sequelize-integration). |
| 5 | +> warning **Warning** In this article, you'll learn how to create a `DatabaseModule` based on the **Sequelize** package from scratch using custom components. As a consequence, this technique contains a lot of overhead that you can avoid by using the dedicated, out-of-the-box `@nestjs/sequelize` package. To learn more, see [here](/techniques/database#sequelize-integration). |
6 | 6 |
|
7 | 7 | [Sequelize](https://github.com/sequelize/sequelize) is a popular Object Relational Mapper (ORM) written in a vanilla JavaScript, but there is a [sequelize-typescript](https://github.com/RobinBuschmann/sequelize-typescript) TypeScript wrapper which provides a set of decorators and other extras for the base sequelize.
|
8 | 8 |
|
@@ -42,7 +42,7 @@ export const databaseProviders = [
|
42 | 42 | ];
|
43 | 43 | ```
|
44 | 44 |
|
45 |
| -> warning **Hint** Following best practices, we declared the custom provider in the separated file which has a `*.providers.ts` suffix. |
| 45 | +> info **Hint** Following best practices, we declared the custom provider in the separated file which has a `*.providers.ts` suffix. |
46 | 46 |
|
47 | 47 | Then, we need to export these providers to make them **accessible** for the rest part of the application.
|
48 | 48 |
|
@@ -94,7 +94,7 @@ export const catsProviders = [
|
94 | 94 | ];
|
95 | 95 | ```
|
96 | 96 |
|
97 |
| -> **Notice** In the real-world applications you should avoid **magic strings**. Both `CATS_REPOSITORY` and `SEQUELIZE` should be kept in the separated `constants.ts` file. |
| 97 | +> warning **Warning** In the real-world applications you should avoid **magic strings**. Both `CATS_REPOSITORY` and `SEQUELIZE` should be kept in the separated `constants.ts` file. |
98 | 98 |
|
99 | 99 | In Sequelize, we use static methods to manipulate the data, and thus we created an **alias** here.
|
100 | 100 |
|
@@ -140,4 +140,4 @@ import { DatabaseModule } from '../database/database.module';
|
140 | 140 | export class CatsModule {}
|
141 | 141 | ```
|
142 | 142 |
|
143 |
| -> warning **Hint** Do not forget to import the `CatsModule` into the root `ApplicationModule`. |
| 143 | +> info **Hint** Do not forget to import the `CatsModule` into the root `ApplicationModule`. |
0 commit comments