-
-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathAuthorEntity.ts
More file actions
28 lines (22 loc) · 812 Bytes
/
AuthorEntity.ts
File metadata and controls
28 lines (22 loc) · 812 Bytes
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
import {Entity, Column, PrimaryColumn, OneToMany} from "typeorm";
import {Activity} from "./Activity";
import {ExtendedSnoowrap} from "../../Utils/SnoowrapClients";
import {SnoowrapActivity} from "../Infrastructure/Reddit";
import {RedditUser} from "snoowrap/dist/objects";
@Entity({name: 'Author'})
export class AuthorEntity {
@Column("varchar", {length: 20, nullable: true})
id?: string;
@PrimaryColumn("varchar", {length: 200})
name!: string;
@OneToMany(type => Activity, act => act.author)
activities!: Promise<Activity[]>
constructor(data?: any) {
if(data !== undefined) {
this.name = data.name;
}
}
toSnoowrap(client: ExtendedSnoowrap): RedditUser {
return new RedditUser({name: this.name, id: this.id}, client, false);
}
}