Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
pleerock authored Oct 18, 2017
2 parents 8297a0d + d565fc4 commit b416d1a
Show file tree
Hide file tree
Showing 313 changed files with 14,302 additions and 7,385 deletions.
229 changes: 115 additions & 114 deletions CHANGELOG.md

Large diffs are not rendered by default.

38 changes: 38 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,3 +122,41 @@ from the main (upstream) repository:
git pull --ff upstream master
```
## Financial contributions
We also welcome financial contributions in full transparency on our [open collective](https://opencollective.com/typeorm).
Anyone can file an expense. If the expense makes sense for the development of the community, it will be "merged" in the ledger of our open collective by the core contributors and the person who filed the expense will be reimbursed.
## Credits
### Contributors
Thank you to all the people who have already contributed to typeorm!
<a href="graphs/contributors"><img src="https://opencollective.com/typeorm/contributors.svg?width=890" /></a>
### Backers
Thank you to all our backers! [[Become a backer](https://opencollective.com/typeorm#backer)]
<a href="https://opencollective.com/typeorm#backers" target="_blank"><img src="https://opencollective.com/typeorm/backers.svg?width=890"></a>
### Sponsors
Thank you to all our sponsors! (please ask your company to also support this open source project by [becoming a sponsor](https://opencollective.com/typeorm#sponsor))
<a href="https://opencollective.com/typeorm/sponsor/0/website" target="_blank"><img src="https://opencollective.com/typeorm/sponsor/0/avatar.svg"></a>
<a href="https://opencollective.com/typeorm/sponsor/1/website" target="_blank"><img src="https://opencollective.com/typeorm/sponsor/1/avatar.svg"></a>
<a href="https://opencollective.com/typeorm/sponsor/2/website" target="_blank"><img src="https://opencollective.com/typeorm/sponsor/2/avatar.svg"></a>
<a href="https://opencollective.com/typeorm/sponsor/3/website" target="_blank"><img src="https://opencollective.com/typeorm/sponsor/3/avatar.svg"></a>
<a href="https://opencollective.com/typeorm/sponsor/4/website" target="_blank"><img src="https://opencollective.com/typeorm/sponsor/4/avatar.svg"></a>
<a href="https://opencollective.com/typeorm/sponsor/5/website" target="_blank"><img src="https://opencollective.com/typeorm/sponsor/5/avatar.svg"></a>
<a href="https://opencollective.com/typeorm/sponsor/6/website" target="_blank"><img src="https://opencollective.com/typeorm/sponsor/6/avatar.svg"></a>
<a href="https://opencollective.com/typeorm/sponsor/7/website" target="_blank"><img src="https://opencollective.com/typeorm/sponsor/7/avatar.svg"></a>
<a href="https://opencollective.com/typeorm/sponsor/8/website" target="_blank"><img src="https://opencollective.com/typeorm/sponsor/8/avatar.svg"></a>
<a href="https://opencollective.com/typeorm/sponsor/9/website" target="_blank"><img src="https://opencollective.com/typeorm/sponsor/9/avatar.svg"></a>
34 changes: 19 additions & 15 deletions README-zh_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,12 @@ TypeORM可以帮助开发者专注于业务逻辑,而不用过于担心数据

TypeORM参考了很多其他优秀ORM的实现, 比如 [Hibernate](http://hibernate.org/orm/), [Doctrine](http://www.doctrine-project.org/)[Entity Framework](https://www.asp.net/entity-framework).

## Note

This documentation is not up-to-date.
See latest english documentation on the [website](http://typeorm.io).
Contributions are welcomed.

## 安装

1. 安装TypeORM:
Expand Down Expand Up @@ -75,7 +81,7 @@ TypeORM在Node.JS 4.0或以上版本上测试通过。

TypeORM可以在浏览器环境中工作,并且试验性的支持WebSQL
如果在浏览器环境中使用TypeORM需要使用 `npm i typeorm-browser` 来替代 `typeorm`.
更多相关可以参考[这里](https://typeorm.github.io/usage-in-browser.html)[这个例子](https://github.com/typeorm/browser-example).
更多相关可以参考[这里](https://typeorm.io)[这个例子](https://github.com/typeorm/browser-example).

## 快速开始

Expand Down Expand Up @@ -259,7 +265,7 @@ createConnection({
entities: [
Photo
],
autoSchemaSync: true,
synchronize: true,
}).then(connection => {
// 这里可以写实体操作相关的代码
}).catch(error => console.log(error));
Expand All @@ -271,7 +277,7 @@ mysql, mariadb, postgres, sqlite, mssql or oracle.

把Photo实体加到数据连接的实体列表中,所有需要在这个连接下使用的实体都必须加到这个列表中。

`autoSchemaSync`选项可以在应用启动时确保你的实体和数据库保持同步。
`synchronize`选项可以在应用启动时确保你的实体和数据库保持同步。

### 引用目录下的所有实体

Expand All @@ -293,7 +299,7 @@ createConnection({
entities: [
__dirname + "/entity/*.js"
],
autoSchemaSync: true,
synchronize: true,
}).then(connection => {
// here you can start to work with your entities
}).catch(error => console.log(error));
Expand Down Expand Up @@ -333,7 +339,7 @@ createConnection(/*...*/).then(connection => {
photo.isPublished = true;

connection.manager
.persist(photo)
.save(photo)
.then(photo => {
console.log("Photo has been saved");
});
Expand All @@ -358,7 +364,7 @@ createConnection(/*...*/).then(async connection => {
photo.views = 1;
photo.isPublished = true;

await connection.manager.persist(photo);
await connection.manager.save(photo);
console.log("Photo has been saved");

}).catch(error => console.log(error));
Expand Down Expand Up @@ -403,7 +409,7 @@ createConnection(/*...*/).then(async connection => {

let photoRepository = connection.getRepository(Photo);

await photoRepository.persist(photo);
await photoRepository.save(photo);
console.log("Photo has been saved");

let savedPhotos = await photoRepository.find();
Expand Down Expand Up @@ -458,7 +464,7 @@ createConnection(/*...*/).then(async connection => {
/*...*/
let photoToUpdate = await photoRepository.findOneById(1);
photoToUpdate.name = "Me, my friends and polar bears";
await photoRepository.persist(photoToUpdate);
await photoRepository.save(photoToUpdate);

}).catch(error => console.log(error));
```
Expand Down Expand Up @@ -577,10 +583,10 @@ createConnection(/*...*/).then(async connection => {
let metadataRepository = connection.getRepository(PhotoMetadata);

// 先来把photo存到数据库
await photoRepository.persist(photo);
await photoRepository.save(photo);

// photo存完了,再存下photo的元信息
await metadataRepository.persist(metadata);
await metadataRepository.save(metadata);

// 搞定
console.log("metadata is saved, and relation between metadata and photo is created in the database too");
Expand Down Expand Up @@ -730,7 +736,7 @@ createConnection(options).then(async connection => {
let photoRepository = connection.getRepository(Photo);

// 存photo
await photoRepository.persist(photo);
await photoRepository.save(photo);
// photo metadata也自动存上了
console.log("Photo is saved, photo metadata is saved too.")

Expand Down Expand Up @@ -903,8 +909,8 @@ photo2.albums = [album2];
let photoRepository = connection.getRepository(Photo);

// 依次存储photos,由于cascade,albums也同样会自动存起来
await photoRepository.persist(photo1);
await photoRepository.persist(photo2);
await photoRepository.save(photo1);
await photoRepository.save(photo2);

console.log("Both photos have been saved");
```
Expand Down Expand Up @@ -933,5 +939,3 @@ let photos = await photoRepository
并且只会得到10个结果(分页每页个数决定的),
所得结果是以id的倒序排序的,
Photo的albums是左联接,photo的metadata是内联接。

更多关于QueryBuilder可以查看[这里](https://typeorm.github.io/query-builder.html).
Loading

0 comments on commit b416d1a

Please sign in to comment.