UNPKG

@wearesage/schema

Version:

A flexible schema definition and validation system for TypeScript with multi-database support

37 lines (29 loc) 899 B
import { Entity, Property, Id, ManyToMany, OneToMany, Index, Timestamp, Auth , Labels } from '../core/decorators'; ; import { Space } from './Space'; import { User } from './User'; @Entity() @Labels(['Team']) @Auth({ permissions: ['user'] }) // Users can access teams they belong to export class Team { @Id() id!: string; @Property({ required: true }) @Index() name!: string; @Property() description?: string; // Users who own this team (have admin permissions) @ManyToMany({ target: () => User, inverse: 'ownedTeams' }) owners!: User[]; // Users who are members of this team @ManyToMany({ target: () => User, inverse: 'teams' }) members!: User[]; // Spaces belonging to this team @OneToMany({ target: () => Space, inverse: 'team' }) spaces!: Space[]; @Timestamp({ onCreate: true }) createdAt!: Date; @Timestamp({ onUpdate: true }) updatedAt!: Date; }