From 4727c7ceed90e2b38eb82be9ec022d0ba9805b12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20=C5=A0vanda?= <46406259+Papooch@users.noreply.github.com> Date: Mon, 1 Jul 2024 20:56:56 +0200 Subject: [PATCH] docs(transactional): fix mistakes and typos --- .../01-transactional/01-prisma-adapter.md | 4 ++-- .../01-transactional/02-knex-adapter.md | 8 ++++---- .../01-transactional/03-kysely-adapter.md | 8 ++++---- .../01-transactional/04-pg-promise-adapter.md | 2 +- .../01-transactional/05-typeorm-adapter.md | 6 ++++-- .../01-transactional/06-mongodb-adapter.md | 6 +++--- 6 files changed, 18 insertions(+), 16 deletions(-) diff --git a/docs/docs/06_plugins/01_available-plugins/01-transactional/01-prisma-adapter.md b/docs/docs/06_plugins/01_available-plugins/01-transactional/01-prisma-adapter.md index b553fc21..aea9d887 100644 --- a/docs/docs/06_plugins/01_available-plugins/01-transactional/01-prisma-adapter.md +++ b/docs/docs/06_plugins/01_available-plugins/01-transactional/01-prisma-adapter.md @@ -50,7 +50,7 @@ ClsModule.forRoot({ :::important -The `prismaInjectionToken` is the token under which an instance of `PrismaClient` provided. Usually, in Nest, this the custom `PrismaService` class which `extends PrismaClient` and is exported from a custom module. +The `prismaInjectionToken` is the token under which an instance of [`PrismaClient`](https://www.prisma.io/docs/orm/prisma-client/setup-and-configuration/introduction) provided. Usually, in Nest, this the custom `PrismaService` class which `extends PrismaClient` and is exported from a custom module. ::: @@ -72,7 +72,7 @@ class UserService { // highlight-start // both methods are executed in the same transaction const user = await this.userRepository.createUser('John'); - const foundUser = await this.userRepository.getUserById(r1.id); + const foundUser = await this.userRepository.getUserById(user.id); // highlight-end assert(foundUser.id === user.id); } diff --git a/docs/docs/06_plugins/01_available-plugins/01-transactional/02-knex-adapter.md b/docs/docs/06_plugins/01_available-plugins/01-transactional/02-knex-adapter.md index 13b54d11..15d00174 100644 --- a/docs/docs/06_plugins/01_available-plugins/01-transactional/02-knex-adapter.md +++ b/docs/docs/06_plugins/01_available-plugins/01-transactional/02-knex-adapter.md @@ -36,11 +36,11 @@ ClsModule.forRoot({ plugins: [ new ClsPluginTransactional({ imports: [ - // module in which the Knex is provided + // module in which Knex is provided KnexModule ], adapter: new TransactionalAdapterKnex({ - // the injection token of the Knex client + // the injection token of the Knex client instance knexInstanceToken: KNEX, }), }), @@ -50,7 +50,7 @@ ClsModule.forRoot({ ## Typing & usage -The `tx` property on the `TransactionHost` is typed as `Knex`. +The `tx` property on the `TransactionHost` is typed as [`Knex`](https://knexjs.org/guide/query-builder.html#knex). ## Example @@ -64,7 +64,7 @@ class UserService { // highlight-start // both methods are executed in the same transaction const user = await this.userRepository.createUser('John'); - const foundUser = await this.userRepository.getUserById(r1.id); + const foundUser = await this.userRepository.getUserById(user.id); // highlight-end assert(foundUser.id === user.id); } diff --git a/docs/docs/06_plugins/01_available-plugins/01-transactional/03-kysely-adapter.md b/docs/docs/06_plugins/01_available-plugins/01-transactional/03-kysely-adapter.md index 1f83cd17..239b110a 100644 --- a/docs/docs/06_plugins/01_available-plugins/01-transactional/03-kysely-adapter.md +++ b/docs/docs/06_plugins/01_available-plugins/01-transactional/03-kysely-adapter.md @@ -36,11 +36,11 @@ ClsModule.forRoot({ plugins: [ new ClsPluginTransactional({ imports: [ - // module in which the Kysely is provided + // module in which Kysely is provided KyselyModule ], adapter: new TransactionalAdapterKysely({ - // the injection token of the Kysely client + // the injection token of the Kysely client instance kyselyInstanceToken: KYSELY, }), }), @@ -50,7 +50,7 @@ ClsModule.forRoot({ ## Typing & usage -The `tx` property on the `TransactionHost` is typed as `Kysely` by default. To get the full typing, you need to supply your database type as the type parameter for the `TransactionalAdapterKysely` when injecting it: +The `tx` property on the `TransactionHost` is typed as [`Kysely`](https://kysely-org.github.io/kysely-apidoc/classes/Kysely.html) by default. To get the full typing, you need to supply your database type as the type parameter for the `TransactionalAdapterKysely` when injecting it: ```ts constructor( @@ -102,7 +102,7 @@ class UserService { // highlight-start // both methods are executed in the same transaction const user = await this.userRepository.createUser('John'); - const foundUser = await this.userRepository.getUserById(r1.id); + const foundUser = await this.userRepository.getUserById(user.id); // highlight-end assert(foundUser.id === user.id); } diff --git a/docs/docs/06_plugins/01_available-plugins/01-transactional/04-pg-promise-adapter.md b/docs/docs/06_plugins/01_available-plugins/01-transactional/04-pg-promise-adapter.md index 56a8818f..ccc76181 100644 --- a/docs/docs/06_plugins/01_available-plugins/01-transactional/04-pg-promise-adapter.md +++ b/docs/docs/06_plugins/01_available-plugins/01-transactional/04-pg-promise-adapter.md @@ -72,7 +72,7 @@ class UserService { 'John', 'john@acme.com', ); - const foundUser = await this.userRepository.getUserById(r1.id); + const foundUser = await this.userRepository.getUserById(user.id); // highlight-end assert(foundUser.id === user.id); } diff --git a/docs/docs/06_plugins/01_available-plugins/01-transactional/05-typeorm-adapter.md b/docs/docs/06_plugins/01_available-plugins/01-transactional/05-typeorm-adapter.md index eac49e9f..21b323ea 100644 --- a/docs/docs/06_plugins/01_available-plugins/01-transactional/05-typeorm-adapter.md +++ b/docs/docs/06_plugins/01_available-plugins/01-transactional/05-typeorm-adapter.md @@ -64,7 +64,9 @@ When using with `@nestjs/typeorm`, the data source token needs to be retrieved w ```ts import { getDataSourceToken } from '@nestjs/typeorm'; // ... -dataSourceToken: getDataSourceToken(), +new TransactionalAdapterTypeOrm({ + dataSourceToken: getDataSourceToken(), +}); ``` ::: @@ -85,7 +87,7 @@ class UserService { // highlight-start // both methods are executed in the same transaction const user = await this.userRepository.createUser('John'); - const foundUser = await this.userRepository.getUserById(r1.id); + const foundUser = await this.userRepository.getUserById(user.id); // highlight-end assert(foundUser.id === user.id); } diff --git a/docs/docs/06_plugins/01_available-plugins/01-transactional/06-mongodb-adapter.md b/docs/docs/06_plugins/01_available-plugins/01-transactional/06-mongodb-adapter.md index 42b86b35..d5154f98 100644 --- a/docs/docs/06_plugins/01_available-plugins/01-transactional/06-mongodb-adapter.md +++ b/docs/docs/06_plugins/01_available-plugins/01-transactional/06-mongodb-adapter.md @@ -76,9 +76,9 @@ class UserService { // highlight-start // both methods are executed in the same transaction const user = await this.userRepository.createUser('John'); - const foundUser = await this.userRepository.getUserById(r1.id); + const foundUser = await this.userRepository.getUserById(user._id); // highlight-end - assert(foundUser.id === user.id); + assert(foundUser._id === user._id); } } ``` @@ -93,7 +93,7 @@ class UserRepository { ) {} async getUserById(id: ObjectId) { - // txHost.tx is typed as Knex + // txHost.tx is typed as ClientSession return this.mongoClient.db('default').collection('user').findOne( { _id: id }, // highlight-start