Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: fix javascript usage examples #7031

Merged
merged 1 commit into from
Jan 12, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions docs/usage-with-javascript.md
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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: {
Expand All @@ -87,7 +91,7 @@ module.exports = {
generated: true
},
title: {
type: "string"
type: "varchar"
},
text: {
type: "text"
Expand All @@ -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.
21 changes: 14 additions & 7 deletions docs/zh_CN/usage-with-javascript.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down Expand Up @@ -54,7 +57,9 @@ typeorm
##### entity/Category.js

```typescript
module.exports = {
var EntitySchema = require("typeorm").EntitySchema;

module.exports = new EntitySchema({
name: "Category",
columns: {
id: {
Expand All @@ -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: {
Expand All @@ -81,7 +88,7 @@ module.exports = {
generated: true
},
title: {
type: "string"
type: "varchar"
},
text: {
type: "text"
Expand All @@ -95,7 +102,7 @@ module.exports = {
cascade: true
}
}
};
});
```

您可以查看此示例[typeorm/javascript-example](https://github.com/typeorm/javascript-example)以了解更多信息。