omnivore/packages/api/src/entity/user.ts

57 lines
1.2 KiB
TypeScript
Raw Normal View History

2022-02-11 17:24:33 +00:00
import {
Column,
CreateDateColumn,
Entity,
OneToMany,
OneToOne,
PrimaryGeneratedColumn,
UpdateDateColumn,
} from 'typeorm'
import { MembershipTier, RegistrationType } from '../datalayer/user/model'
import { NewsletterEmail } from './newsletter_email'
import { Profile } from './profile'
2022-02-21 08:53:04 +00:00
import { Label } from './label'
import { Subscription } from './subscription'
2022-02-11 17:24:33 +00:00
@Entity()
export class User {
2022-02-11 17:24:33 +00:00
@PrimaryGeneratedColumn('uuid')
id!: string
@Column('text')
name!: string
@Column({ type: 'enum', enum: RegistrationType })
source!: string
@Column('text')
email!: string
@Column('text')
sourceUserId!: string
@Column({ type: 'enum', enum: MembershipTier })
membership!: string
@CreateDateColumn()
createdAt!: Date
@UpdateDateColumn()
updatedAt!: Date
@OneToMany(() => NewsletterEmail, (newsletterEmail) => newsletterEmail.user)
newsletterEmails?: NewsletterEmail[]
@OneToOne(() => Profile, (profile) => profile.user)
profile!: Profile
@Column('varchar', { length: 255, nullable: true })
password?: string
2022-02-21 08:53:04 +00:00
@OneToMany(() => Label, (label) => label.user)
labels?: Label[]
@OneToMany(() => Subscription, (subscription) => subscription.user)
subscriptions?: Subscription[]
2022-02-11 17:24:33 +00:00
}