NestJS - Database with TypeORMWhich of the following is the correct way to start a transaction using TypeORM's DataSource in NestJS?AdataSource.transaction(async (manager) => { /* operations */ })BdataSource.startTransaction(() => { /* operations */ })CdataSource.begin(async () => { /* operations */ })DdataSource.runTransaction(() => { /* operations */ })Check Answer
Step-by-Step SolutionSolution:Step 1: Recall TypeORM transaction methodTypeORM uses dataSource.transaction with an async callback to run transactional code.Step 2: Check method namesOnly dataSource.transaction(async (manager) => { /* operations */ }) uses the correct method name and async callback pattern.Final Answer:dataSource.transaction(async (manager) => { /* operations */ }) -> Option AQuick Check:Correct method is transaction with async callback [OK]Quick Trick: Use dataSource.transaction with async callback [OK]Common Mistakes:Using non-existent methods like startTransactionOmitting async keyword in callbackUsing wrong method names like begin or runTransaction
Master "Database with TypeORM" in NestJS9 interactive learning modes - each teaches the same concept differentlyLearnWhyDeepVisualTryChallengeProjectRecallPerf
More NestJS Quizzes Authentication - Protected routes with guards - Quiz 14medium Database with Prisma - Why Prisma offers type-safe database access - Quiz 4medium Database with Prisma - CRUD with Prisma - Quiz 12easy Database with TypeORM - Migrations - Quiz 2easy Database with TypeORM - Relations (OneToMany, ManyToOne, ManyToMany) - Quiz 2easy Guards - Guard binding levels - Quiz 11easy Interceptors - Interceptor interface - Quiz 13medium Interceptors - Response transformation - Quiz 11easy Interceptors - Timeout interceptor - Quiz 1easy Middleware - Third-party middleware (cors, helmet) - Quiz 1easy