/
dimamir
/
undb
Обзор
Документация
Войти
/
dimamir
/
undb
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
develop
packages/table/src/methods/duplicate-view.method.ts
33 строки
1022 B
nichenqin
fix: fix event spaceis
18 окт 2024, 11:51
18 окт 2024, 11:51
4b42997
Код
Авторство
О чём код?
import { applyRules, type Option } from "@undb/domain" import type { IDuplicateViewDTO } from "../dto/duplicate-view.dto" import { ViewCreatedEvent } from "../events/view-created.event" import type { View } from "../modules" import { ViewNameShouldBeUnique } from "../rules/view-name-should-be-unique.rule" import { type TableComositeSpecification } from "../specifications" import type { TableDo } from "../table.do" export function duplicateViewMethod( this: TableDo, dto: IDuplicateViewDTO, ): { spec: Option<TableComositeSpecification>; view: View } { const view = this.views.getViewById(dto.viewId) const spec = view.$duplicate(this, dto) const names = this.views.views.map((v) => v.name.value) applyRules(new ViewNameShouldBeUnique(names)) if (spec.isSome()) { spec.unwrap().mutate(this) const event = new ViewCreatedEvent( { tableId: this.id.value, view: view.toJSON(), }, this.spaceId, ) this.addDomainEvent(event) } return { spec, view } }