From 99f92df7dde540a4ebb1c84afd442f936f8a19d3 Mon Sep 17 00:00:00 2001 From: Author Ed Colvin Date: Fri, 6 Nov 2020 23:03:18 -0900 Subject: [PATCH] docs: fix javascript usage examples --- docs/usage-with-javascript.md | 16 ++++++++++------ docs/zh_CN/usage-with-javascript.md | 21 ++++++++++++++------- 2 files changed, 24 insertions(+), 13 deletions(-) diff --git a/docs/usage-with-javascript.md b/docs/usage-with-javascript.md index 0ecf7cbf09..7eacd79ee8 100644 --- a/docs/usage-with-javascript.md +++ b/docs/usage-with-javascript.md @@ -58,7 +58,9 @@ typeorm.createConnection({ ##### entity/Category.js ```typescript -module.exports = { +var EntitySchema = require("typeorm").EntitySchema; + +module.exports = new EntitySchema({ name: "Category", // Will use table name `category` as default behaviour. tableName: "categories", // Optional: Provide `tableName` property to override the default behaviour for table name. columns: { @@ -68,16 +70,18 @@ module.exports = { generated: true }, name: { - type: "string" + type: "varchar" } } -}; +}); ``` ##### entity/Post.js ```typescript -module.exports = { +var EntitySchema = require("typeorm").EntitySchema; + +module.exports = new EntitySchema({ name: "Post", // Will use table name `post` as default behaviour. tableName: "posts", // Optional: Provide `tableName` property to override the default behaviour for table name. columns: { @@ -87,7 +91,7 @@ module.exports = { generated: true }, title: { - type: "string" + type: "varchar" }, text: { type: "text" @@ -101,7 +105,7 @@ module.exports = { cascade: true } } -}; +}); ``` You can checkout this example [typeorm/javascript-example](https://github.com/typeorm/javascript-example) to learn more. diff --git a/docs/zh_CN/usage-with-javascript.md b/docs/zh_CN/usage-with-javascript.md index c3d193d018..4a8922dee2 100644 --- a/docs/zh_CN/usage-with-javascript.md +++ b/docs/zh_CN/usage-with-javascript.md @@ -17,7 +17,10 @@ typeorm password: "admin", database: "test", synchronize: true, - entitySchemas: [require("./entity/Post"), require("./entity/Category")] + entities: [ + require("./entity/Post"), + require("./entity/Category") + ] }) .then(function(connection) { var category1 = { @@ -54,7 +57,9 @@ typeorm ##### entity/Category.js ```typescript -module.exports = { +var EntitySchema = require("typeorm").EntitySchema; + +module.exports = new EntitySchema({ name: "Category", columns: { id: { @@ -63,16 +68,18 @@ module.exports = { generated: true }, name: { - type: "string" + type: "varchar" } } -}; +}); ``` ##### entity/Post.js ```typescript -module.exports = { +var EntitySchema = require("typeorm").EntitySchema; + +module.exports = new EntitySchema({ name: "Post", columns: { id: { @@ -81,7 +88,7 @@ module.exports = { generated: true }, title: { - type: "string" + type: "varchar" }, text: { type: "text" @@ -95,7 +102,7 @@ module.exports = { cascade: true } } -}; +}); ``` 您可以查看此示例[typeorm/javascript-example](https://github.com/typeorm/javascript-example)以了解更多信息。