import { Column, Entity, PrimaryGeneratedColumn, Unique } from 'typeorm'

@Entity()
@Unique('user_date', ['userId', 'date'])
export class TokenUsage {
    @PrimaryGeneratedColumn()
    id: number

    @Column()
    userId: number

    @Column({ type: 'date' })
    date: string

    @Column({ default: 0 })
    usage: number

    constructor(data: Partial<TokenUsage>) {
        Object.assign(this, data)
    }
}
