File tree Expand file tree Collapse file tree 6 files changed +20
-14
lines changed Expand file tree Collapse file tree 6 files changed +20
-14
lines changed Original file line number Diff line number Diff line change 2222 " typeorm-example"
2323 ],
2424 "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"
2827 }
2928}
Original file line number Diff line number Diff line change 11var typeorm = require ( "typeorm" ) ;
2+ var EntitySchema = typeorm . EntitySchema ;
23
34typeorm . createConnection ( {
45 type : "mysql" ,
@@ -8,9 +9,9 @@ typeorm.createConnection({
89 password : "test" ,
910 database : "test" ,
1011 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" ) ) ,
1415 ]
1516} ) . then ( function ( connection ) {
1617
Original file line number Diff line number Diff line change 11var typeorm = require ( "typeorm" ) ;
2+ var EntitySchema = typeorm . EntitySchema ;
23
34typeorm . createConnection ( {
45 type : "mysql" ,
@@ -8,8 +9,9 @@ typeorm.createConnection({
89 password : "test" ,
910 database : "test" ,
1011 synchronize : true ,
11- entitySchemas : [
12- __dirname + "/entity/*.json"
12+ entities : [
13+ new EntitySchema ( require ( "./entity/post.json" ) ) ,
14+ new EntitySchema ( require ( "./entity/category.json" ) ) ,
1315 ]
1416} ) . then ( function ( connection ) {
1517
Original file line number Diff line number Diff line change 1+ const EntitySchema = require ( "typeorm" ) . EntitySchema ; // import {EntitySchema} from "typeorm";
12const Category = require ( "../model/Category" ) . Category ; // import {Category} from "../model/Category";
23
3- module . exports = {
4+ module . exports = new EntitySchema ( {
5+ name : "Category" ,
46 target : Category ,
57 columns : {
68 id : {
@@ -12,4 +14,4 @@ module.exports = {
1214 type : "varchar"
1315 }
1416 }
15- } ;
17+ } ) ;
Original file line number Diff line number Diff line change 1+ const EntitySchema = require ( "typeorm" ) . EntitySchema ; // import {EntitySchema} from "typeorm";
12const Post = require ( "../model/Post" ) . Post ; // import {Post} from "../model/Post";
23const Category = require ( "../model/Category" ) . Category ; // import {Category} from "../model/Category";
34
4- module . exports = {
5+ module . exports = new EntitySchema ( {
6+ name : "Post" ,
57 target : Post ,
68 columns : {
79 id : {
@@ -18,10 +20,10 @@ module.exports = {
1820 } ,
1921 relations : {
2022 categories : {
21- target : ( ) => Category ,
23+ target : " Category" ,
2224 type : "many-to-many" ,
2325 joinTable : true ,
2426 cascadeInsert : true
2527 }
2628 }
27- } ;
29+ } ) ;
Original file line number Diff line number Diff line change @@ -11,7 +11,7 @@ typeorm.createConnection({
1111 database : "test" ,
1212 synchronize : true ,
1313 logging : false ,
14- entitySchemas : [
14+ entities : [
1515 require ( "./entity/PostSchema" ) ,
1616 require ( "./entity/CategorySchema" )
1717 ]
You can’t perform that action at this time.
0 commit comments