mirror of
https://github.com/toeverything/AFFiNE.git
synced 2026-02-15 05:37:32 +00:00
refactor(server): rename tx to db (#9867)
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
import { Inject, Logger } from '@nestjs/common';
|
||||
import { TransactionHost } from '@nestjs-cls/transactional';
|
||||
import type { TransactionalAdapterPrisma } from '@nestjs-cls/transactional-adapter-prisma';
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
|
||||
import { Config } from '../base';
|
||||
import type { Models } from '.';
|
||||
@@ -16,13 +15,12 @@ export class BaseModel {
|
||||
@Inject(Config)
|
||||
protected readonly config!: Config;
|
||||
|
||||
@Inject(PrismaClient)
|
||||
protected readonly db!: PrismaClient;
|
||||
|
||||
@Inject(TransactionHost)
|
||||
private readonly txHost!: TransactionHost<TransactionalAdapterPrisma>;
|
||||
|
||||
protected get tx() {
|
||||
protected get db() {
|
||||
// When a transaction is not active, the Transaction instance refers to the default non-transactional instance.
|
||||
// See https://papooch.github.io/nestjs-cls/plugins/available-plugins/transactional#using-the-injecttransaction-decorator
|
||||
return this.txHost.tx;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user