Skip to content

Commit 7ddc37c

Browse files
author
Umed Khudoiberdiev
committed
updated typeorm version to 0.2.0
1 parent dbb898a commit 7ddc37c

File tree

6 files changed

+20
-14
lines changed

6 files changed

+20
-14
lines changed

package.json

+2-3
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@
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
}

src/app1-es5/index.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
var typeorm = require("typeorm");
2+
var EntitySchema = typeorm.EntitySchema;
23

34
typeorm.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

src/app2-es5-json-schemas/index.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
var typeorm = require("typeorm");
2+
var EntitySchema = typeorm.EntitySchema;
23

34
typeorm.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

src/app3-es6/entity/CategorySchema.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
const EntitySchema = require("typeorm").EntitySchema; // import {EntitySchema} from "typeorm";
12
const 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+
});

src/app3-es6/entity/PostSchema.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
1+
const EntitySchema = require("typeorm").EntitySchema; // import {EntitySchema} from "typeorm";
12
const Post = require("../model/Post").Post; // import {Post} from "../model/Post";
23
const 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+
});

src/app3-es6/index.js

+1-1
Original file line numberDiff line numberDiff 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
]

0 commit comments

Comments
 (0)