File tree 6 files changed +20
-14
lines changed
6 files changed +20
-14
lines changed Original file line number Diff line number Diff line change 22
22
" typeorm-example"
23
23
],
24
24
"dependencies" : {
25
- "mysql" : " ^2.14.1" ,
26
- "reflect-metadata" : " ^0.1.10" ,
27
- "typeorm" : " ^0.1.0"
25
+ "mysql" : " ^2.15.0" ,
26
+ "typeorm" : " ^0.2.0"
28
27
}
29
28
}
Original file line number Diff line number Diff line change 1
1
var typeorm = require ( "typeorm" ) ;
2
+ var EntitySchema = typeorm . EntitySchema ;
2
3
3
4
typeorm . createConnection ( {
4
5
type : "mysql" ,
@@ -8,9 +9,9 @@ typeorm.createConnection({
8
9
password : "test" ,
9
10
database : "test" ,
10
11
synchronize : true ,
11
- entitySchemas : [
12
- require ( "./entity/Post" ) ,
13
- require ( "./entity/Category" )
12
+ entities : [
13
+ new EntitySchema ( require ( "./entity/Post" ) ) ,
14
+ new EntitySchema ( require ( "./entity/Category" ) ) ,
14
15
]
15
16
} ) . then ( function ( connection ) {
16
17
Original file line number Diff line number Diff line change 1
1
var typeorm = require ( "typeorm" ) ;
2
+ var EntitySchema = typeorm . EntitySchema ;
2
3
3
4
typeorm . createConnection ( {
4
5
type : "mysql" ,
@@ -8,8 +9,9 @@ typeorm.createConnection({
8
9
password : "test" ,
9
10
database : "test" ,
10
11
synchronize : true ,
11
- entitySchemas : [
12
- __dirname + "/entity/*.json"
12
+ entities : [
13
+ new EntitySchema ( require ( "./entity/post.json" ) ) ,
14
+ new EntitySchema ( require ( "./entity/category.json" ) ) ,
13
15
]
14
16
} ) . then ( function ( connection ) {
15
17
Original file line number Diff line number Diff line change
1
+ const EntitySchema = require ( "typeorm" ) . EntitySchema ; // import {EntitySchema} from "typeorm";
1
2
const Category = require ( "../model/Category" ) . Category ; // import {Category} from "../model/Category";
2
3
3
- module . exports = {
4
+ module . exports = new EntitySchema ( {
5
+ name : "Category" ,
4
6
target : Category ,
5
7
columns : {
6
8
id : {
@@ -12,4 +14,4 @@ module.exports = {
12
14
type : "varchar"
13
15
}
14
16
}
15
- } ;
17
+ } ) ;
Original file line number Diff line number Diff line change
1
+ const EntitySchema = require ( "typeorm" ) . EntitySchema ; // import {EntitySchema} from "typeorm";
1
2
const Post = require ( "../model/Post" ) . Post ; // import {Post} from "../model/Post";
2
3
const Category = require ( "../model/Category" ) . Category ; // import {Category} from "../model/Category";
3
4
4
- module . exports = {
5
+ module . exports = new EntitySchema ( {
6
+ name : "Post" ,
5
7
target : Post ,
6
8
columns : {
7
9
id : {
@@ -18,10 +20,10 @@ module.exports = {
18
20
} ,
19
21
relations : {
20
22
categories : {
21
- target : ( ) => Category ,
23
+ target : " Category" ,
22
24
type : "many-to-many" ,
23
25
joinTable : true ,
24
26
cascadeInsert : true
25
27
}
26
28
}
27
- } ;
29
+ } ) ;
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ typeorm.createConnection({
11
11
database : "test" ,
12
12
synchronize : true ,
13
13
logging : false ,
14
- entitySchemas : [
14
+ entities : [
15
15
require ( "./entity/PostSchema" ) ,
16
16
require ( "./entity/CategorySchema" )
17
17
]
You can’t perform that action at this time.
0 commit comments