All files / user/entities user.entity.ts

100% Statements 42/42
0% Branches 0/1
0% Functions 0/2
100% Lines 42/42

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 421x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x
import { Column, Entity, JoinTable, ManyToMany, ManyToOne, OneToMany, PrimaryColumn } from "typeorm";
import { Exclude } from "class-transformer";
import { Expertise } from "src/expertise/entities/expertise.entity";
import { Post } from "src/post/entities/post.entity";
import { Badge } from "src/badge/entities/badge.entity";
 
@Entity()
export class User {
    @PrimaryColumn()
        username: string;
 
    @Column()
        name: string;
 
    @Column({ unique: true })
        email: string;
 
    @Exclude()
    @Column({ nullable: false, generated: "increment" })
        id: number;
 
    @Exclude()
    @Column({ nullable: false })
        hashPassword: string;
 
    @Column({ nullable: false, default: 0 })
        xp: number;
    
    @ManyToOne(() => Badge, badge => badge.currentUsers)
        currentBadge: Badge;
    
    @ManyToMany(() => Badge, badge => badge.id)
    @JoinTable()
        badges: Badge[];
 
    @OneToMany(() => Post, post => post.user)
        post: Post[];
    
    @ManyToMany(() => Expertise, expertise => expertise.users, { onUpdate: "CASCADE" })
    @JoinTable()
        expertises: Expertise[];
}