-
-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathdelete-personal-table-settings.use.case.ts
More file actions
37 lines (32 loc) · 1.53 KB
/
delete-personal-table-settings.use.case.ts
File metadata and controls
37 lines (32 loc) · 1.53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { Inject, Injectable, Scope } from '@nestjs/common';
import AbstractUseCase from '../../../../common/abstract-use.case.js';
import { IGlobalDatabaseContext } from '../../../../common/application/global-database-context.interface.js';
import { BaseType } from '../../../../common/data-injection.tokens.js';
import { FindPersonalTableSettingsDs } from '../data-structures/find-personal-table-settings.ds.js';
import { FoundPersonalTableSettingsDto } from '../dto/found-personal-table-settings.dto.js';
import { buildFoundTableSettingsDto } from '../utils/build-found-table-settings-dto.js';
import { IDeletePersonalTableSettings } from './personal-table-settings.use-cases.interface.js';
@Injectable({ scope: Scope.REQUEST })
export class DeletePersonalTableSettingsUseCase
extends AbstractUseCase<FindPersonalTableSettingsDs, FoundPersonalTableSettingsDto>
implements IDeletePersonalTableSettings
{
constructor(
@Inject(BaseType.GLOBAL_DB_CONTEXT)
protected _dbContext: IGlobalDatabaseContext,
) {
super();
}
public async implementation(inputData: FindPersonalTableSettingsDs): Promise<FoundPersonalTableSettingsDto> {
const { connectionId, userId, tableName } = inputData;
const foundPersonalTableSettings = await this._dbContext.personalTableSettingsRepository.findUserTableSettings(
connectionId,
tableName,
userId,
);
if (foundPersonalTableSettings) {
await this._dbContext.personalTableSettingsRepository.remove(foundPersonalTableSettings);
}
return buildFoundTableSettingsDto(foundPersonalTableSettings);
}
}