mirror of
https://activitypub.software/TransFem-org/Sharkey.git
synced 2024-12-16 10:11:54 +01:00
46 lines
844 B
TypeScript
46 lines
844 B
TypeScript
|
import { Entity, PrimaryColumn, Index, Column, ManyToOne, JoinColumn, RelationId } from 'typeorm';
|
||
|
import { User } from './user';
|
||
|
import { App } from './app';
|
||
|
import { id } from '../id';
|
||
|
|
||
|
@Entity()
|
||
|
export class AccessToken {
|
||
|
@PrimaryColumn(id())
|
||
|
public id: string;
|
||
|
|
||
|
@Column('timestamp with time zone', {
|
||
|
comment: 'The created date of the AccessToken.'
|
||
|
})
|
||
|
public createdAt: Date;
|
||
|
|
||
|
@Index()
|
||
|
@Column('varchar', {
|
||
|
length: 128
|
||
|
})
|
||
|
public token: string;
|
||
|
|
||
|
@Index()
|
||
|
@Column('varchar', {
|
||
|
length: 128
|
||
|
})
|
||
|
public hash: string;
|
||
|
|
||
|
@RelationId((self: AccessToken) => self.user)
|
||
|
public userId: User['id'];
|
||
|
|
||
|
@ManyToOne(type => User, {
|
||
|
onDelete: 'CASCADE'
|
||
|
})
|
||
|
@JoinColumn()
|
||
|
public user: User | null;
|
||
|
|
||
|
@Column(id())
|
||
|
public appId: App['id'];
|
||
|
|
||
|
@ManyToOne(type => App, {
|
||
|
onDelete: 'CASCADE'
|
||
|
})
|
||
|
@JoinColumn()
|
||
|
public app: App | null;
|
||
|
}
|