template sharing
This commit is contained in:
50
listify-api/src/list-templates/list-template-share.entity.ts
Normal file
50
listify-api/src/list-templates/list-template-share.entity.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
import {
|
||||
Column,
|
||||
CreateDateColumn,
|
||||
Entity,
|
||||
Index,
|
||||
JoinColumn,
|
||||
ManyToOne,
|
||||
PrimaryColumn,
|
||||
} from 'typeorm';
|
||||
import { UserEntity } from '../auth/user.entity';
|
||||
import { ListTemplateEntity } from './list-template.entity';
|
||||
|
||||
export type ListTemplateShareRole = 'collaborator';
|
||||
|
||||
@Entity('list_template_shares')
|
||||
@Index(['templateId', 'userId'], { unique: true })
|
||||
export class ListTemplateShareEntity {
|
||||
@PrimaryColumn({ type: 'varchar', length: 36 })
|
||||
id!: string;
|
||||
|
||||
@Index()
|
||||
@Column({ type: 'varchar', length: 36 })
|
||||
templateId!: string;
|
||||
|
||||
@Index()
|
||||
@Column({ type: 'varchar', length: 36 })
|
||||
userId!: string;
|
||||
|
||||
@Column({ type: 'varchar', length: 32, default: 'collaborator' })
|
||||
role!: ListTemplateShareRole;
|
||||
|
||||
@CreateDateColumn({
|
||||
type: 'datetime',
|
||||
precision: 3,
|
||||
default: () => 'CURRENT_TIMESTAMP(3)',
|
||||
})
|
||||
createdAt!: Date;
|
||||
|
||||
@ManyToOne(() => ListTemplateEntity, (template) => template.shares, {
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
@JoinColumn({ name: 'templateId' })
|
||||
template?: ListTemplateEntity;
|
||||
|
||||
@ManyToOne(() => UserEntity, (user) => user.sharedTemplates, {
|
||||
onDelete: 'CASCADE',
|
||||
})
|
||||
@JoinColumn({ name: 'userId' })
|
||||
user?: UserEntity;
|
||||
}
|
||||
Reference in New Issue
Block a user