-
-
Notifications
You must be signed in to change notification settings - Fork 95
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
12 changed files
with
77 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 10 additions & 5 deletions
15
packages/command-handlers/src/handlers/create-table-view.command-handler.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,25 @@ | ||
import { CreateTableViewCommand } from "@undb/commands" | ||
import { CreateTableViewCommand, type ICreateTableViewCommandOutput } from "@undb/commands" | ||
import { commandHandler } from "@undb/cqrs" | ||
import { singleton } from "@undb/di" | ||
import type { ICommandHandler } from "@undb/domain" | ||
import { injectTableService, type ITableService } from "@undb/table" | ||
|
||
@commandHandler(CreateTableViewCommand) | ||
@singleton() | ||
export class CreateTableViewCommandHandler implements ICommandHandler<CreateTableViewCommand, any> { | ||
export class CreateTableViewCommandHandler | ||
implements ICommandHandler<CreateTableViewCommand, ICreateTableViewCommandOutput> | ||
{ | ||
constructor( | ||
@injectTableService() | ||
private readonly service: ITableService, | ||
) {} | ||
|
||
async execute(command: CreateTableViewCommand): Promise<any> { | ||
const table = await this.service.createTableView(command.input) | ||
async execute(command: CreateTableViewCommand): Promise<ICreateTableViewCommandOutput> { | ||
const { table, view } = await this.service.createTableView(command.input) | ||
|
||
return table.id.value | ||
return { | ||
tableId: table.id.value, | ||
viewId: view.id.value, | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 7 additions & 3 deletions
10
packages/table/src/services/methods/create-table-view.method.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,18 @@ | ||
import type { View } from "../../modules" | ||
import type { ICreateTableViewDTO } from "../../modules/views/dto/create-view.dto" | ||
import { TableIdVo } from "../../table-id.vo" | ||
import type { TableDo } from "../../table.do" | ||
import type { TableService } from "../table.service" | ||
|
||
export async function createTableViewMethod(this: TableService, dto: ICreateTableViewDTO): Promise<TableDo> { | ||
export async function createTableViewMethod( | ||
this: TableService, | ||
dto: ICreateTableViewDTO, | ||
): Promise<{ table: TableDo; view: View }> { | ||
const table = (await this.repository.findOneById(new TableIdVo(dto.tableId))).expect("Not found table") | ||
|
||
const spec = table.$createView(dto) | ||
const { spec, view } = table.$createView(dto) | ||
|
||
await this.repository.updateOneById(table, spec) | ||
|
||
return table | ||
return { table, view } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters