-
Notifications
You must be signed in to change notification settings - Fork 6
/
Git.ts
78 lines (68 loc) · 1.63 KB
/
Git.ts
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import {
Entity,
Column,
PrimaryColumn,
DeleteDateColumn,
BeforeInsert,
BeforeUpdate,
OneToOne,
} from "typeorm";
import { Folder } from "./Folder";
@Entity({ name: "gits" })
/** Class representing a git action. */
export class Git {
@PrimaryColumn()
id: string;
@Column()
address: string;
@Column({ nullable: true, default: null })
sha: string;
@Column({ default: false })
isApproved: boolean;
@Column({
type: "bigint",
transformer: {
to: (i: Date | null | undefined): number => (i ? i.getTime() : null),
from: (i: number | null | undefined): Date => (i ? new Date(Math.trunc(i)) : null),
},
})
createdAt: Date;
@Column({
type: "bigint",
nullable: true,
transformer: {
to: (i: Date | null | undefined): number => (i ? i.getTime() : null),
from: (i: number | null | undefined): Date => (i ? new Date(Math.trunc(i)) : null),
},
})
updatedAt: Date;
@DeleteDateColumn({
type: "bigint",
nullable: true,
transformer: {
to: (i: Date | null | undefined): number => (i ? i.getTime() : null),
from: (i: number | null | undefined): Date => (i ? new Date(Math.trunc(i)) : null),
},
})
deletedAt: Date;
/**
* Set the createdAt time to the current time.
*
* @async
* @return {Date} date - Date this job was created.
*/
@BeforeInsert()
async setCreatedAt() {
this.createdAt = new Date();
}
/**
* Set the updatedAt time to the current time.
*
* @async
* @return {Date} date - Date this job was last updated.
*/
@BeforeUpdate()
async setUpdatedAt() {
return (this.updatedAt = new Date());
}
}