/
Post.ts
53 lines (41 loc) · 1018 Bytes
/
Post.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
import {EntitySchemaOptions} from "../../../../src/entity-schema/EntitySchemaOptions";
import {Author} from "./Author";
export class Post {
authorPublisherId: number;
authorId: number;
id: number;
title: string;
author: Author;
}
export const PostSchema: EntitySchemaOptions<Post> = {
name: "Post",
target: Post,
columns: {
authorPublisherId: {
primary: true,
type: Number
},
authorId: {
primary: true,
type: Number
},
id: {
primary: true,
type: Number
},
title: {
type: "varchar"
}
},
relations: {
author: {
target: () => Author,
type: "many-to-one",
eager: true,
joinColumn: [
{ name: "authorPublisherId", referencedColumnName: "publisherId" },
{ name: "authorId", referencedColumnName: "id" },
]
}
}
};