필드
필드는 베이스 테이블의 스키마를 정의합니다. 각 필드에는 유형, 구성, 기본값이 있으며 정렬, 필터링, 그룹화, 카드 표시와 같은 기능을 사용할 수 있습니다.
필드 추가
TypeScript
const table = base.getTableById('tasks')if (!table) throw new Error('Tasks table not found')const title = table.addField('Title', univerAPI.Enum.BaseFieldType.Text)const priority = table.addField( 'Priority', univerAPI.Enum.BaseFieldType.SingleSelect, { field: { config: { options: [ { id: 'high', name: 'High', color: '#ef4444' }, { id: 'low', name: 'Low', color: '#22c55e' }, ], }, }, },)필드 업데이트
TypeScript
priority.setName('Impact')priority.update({ description: 'Business priority' })priority.setConfig({ options: [ { id: 'p0', name: 'P0', color: '#dc2626' }, { id: 'p1', name: 'P1', color: '#f97316' }, ],})필드 유형 변경
TypeScript
priority.changeType(univerAPI.Enum.BaseFieldType.Text, {})필드 유형을 변경하면 기존 값이 정규화될 수 있습니다. 프로덕션 테이블의 스키마를 변경하기 전에 애플리케이션에서 데이터를 검증하세요.
이 가이드는 어떠셨나요?