Skip to content

Commit

Permalink
docs: fix javascript usage examples
Browse files Browse the repository at this point in the history
  • Loading branch information
edcolvin committed Nov 12, 2020
1 parent c683c8e commit 99f92df
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 13 deletions.
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)以了解更多信息。

0 comments on commit 99f92df

Please sign in to comment.