Skip to content

Commit

Permalink
docs: docs
Browse files Browse the repository at this point in the history
Docs

Signed-off-by: Yaapa Hage <[email protected]>
  • Loading branch information
Yaapa Hage committed Jul 8, 2020
1 parent 2a4669f commit dc00546
Show file tree
Hide file tree
Showing 6 changed files with 658 additions and 5,217 deletions.
68 changes: 35 additions & 33 deletions docs/site/Using-TypeORM-with-LoopBack.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@ lang: en
title: 'How to use TypeORM with LoopBack'
keywords: LoopBack 4.0, LoopBack 4, TypeORM
sidebar: lb4_sidebar
permalink: /doc/en/lb4/Using-TypeORM-with-LoopBack.html
permalink: /doc/en/lb4/Using-typeorm-with-loopback.html
---

## Overview

If you would like to use TypeORM with LoopBack, it is possible with the use of
`@loopback/typeorm`. Install it as a dependency in your project.
[TypeORM](https://typeorm.io/) is an ORM for Node.js that can be used with
LoopBack in place of Juggler ORM.

```sh
npm install --save @loopback/typeorm
Expand All @@ -27,27 +27,6 @@ export class MyApplication extends BootMixin(TypeOrmMixin(RestApplication)) {
}
```

### Creating Entities

[Entities](https://typeorm.io/#/entities) are equivalent to LoopBack's Models.
Define the entities as usual and keep them in a directory named `entities`.

```ts
// src/entities/book.entity.ts
import {Entity, Column, PrimaryColumn} from 'typeorm';
@Entity()
export class Photo {
@PrimaryColumn()
id: number;

@Column()
title: string;

@Column()
isPublished: boolean;
}
```

### Creating Connections

[Connections](https://typeorm.io/#/connection) are equivalent to LoopBack's
Expand Down Expand Up @@ -81,7 +60,28 @@ Refer to the
[TypeORM documentation](https://github.com/typeorm/typeorm#installation) for the
supported databases and the underlying drivers.

### Creating controllers
### Creating Entities

[Entities](https://typeorm.io/#/entities) are equivalent to LoopBack's Models.
Define the entities as usual and keep them in a directory named `entities`.

```ts
// src/entities/book.entity.ts
import {Entity, Column, PrimaryColumn} from 'typeorm';
@Entity()
export class Photo {
@PrimaryColumn()
id: number;

@Column()
title: string;

@Column()
isPublished: boolean;
}
```

### Creating Controllers

Controllers continue to work as usual. And you don't have to create repositories
since TypeORM creates them for you; just inject them in the controllers. The
Expand Down Expand Up @@ -120,13 +120,15 @@ export class BookController {

Please note, the current implementation does not support the following:

1. Complete TypeORM to OpenAPI data type conversion (currently only `number`,
`string`, and `boolean` are supported)
2. Full JSON/OpenAPI schema for models, including variants like with/without id,
with/without relations, partial, etc.
3. Json/OpenAPI schema to describe the supported filter format
4. Support for LoopBack-style filters
5. Custom repository classes (e.g. to implement bookRepo.findByTitle(title)).
6. Database migration
1. [Complete TypeORM to OpenAPI data type conversion](https://github.com/strongloop/loopback-next/issues/5893)
(currently only `number`, `string`, and `boolean` are supported)
2. [Full JSON/OpenAPI schema for entities](https://github.com/strongloop/loopback-next/issues/5894),
including variants like with/without id, with/without relations, partial,
etc.
3. [Support for LoopBack-style filters](https://github.com/strongloop/loopback-next/issues/5895)
4. [JSON/OpenAPI schema to describe the supported filter format](https://github.com/strongloop/loopback-next/issues/5896)
5. [Custom repository classes](https://github.com/strongloop/loopback-next/issues/5897)
(e.g. to implement bookRepo.findByTitle(title)).
6. [Database migration](https://github.com/strongloop/loopback-next/issues/5898)

We will be implementing them progressively.
14 changes: 7 additions & 7 deletions docs/site/sidebars/lb4_sidebar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,6 @@ children:
output: 'web, pdf'
children:

- title: 'Using TypeORM'
output: 'web, pdf'
children:
- title: 'How to use TypeORM with LoopBack'
url: Using-TypeORM-with-LoopBack.html
output: 'web, pdf'

- title: 'Building REST APIs'
output: 'web, pdf'
children:
Expand Down Expand Up @@ -249,6 +242,13 @@ children:
url: Database-migrations.html
output: 'web, pdf'

- title: 'Using TypeORM'
output: 'web, pdf'
children:
- title: 'How to use TypeORM with LoopBack'
url: Using-typeorm-with-loopback.html
output: 'web, pdf'

- title: 'Running and debugging apps'
url: Running-and-debugging-apps.html
output: 'web, pdf'
Expand Down
18 changes: 10 additions & 8 deletions extensions/typeorm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,14 +130,16 @@ export class BookController {

Please note, the current implementation does not support the following:

1. Complete TypeORM to OpenAPI data type conversion (currently only `number`,
`string`, and `boolean` are supported)
2. Full JSON/OpenAPI schema for models, including variants like with/without id,
with/without relations, partial, etc.
3. Json/OpenAPI schema to describe the supported filter format
4. Support for LoopBack-style filters
5. Custom repository classes (e.g. to implement bookRepo.findByTitle(title)).
6. Database migration
1. [Complete TypeORM to OpenAPI data type conversion](https://github.com/strongloop/loopback-next/issues/5893)
(currently only `number`, `string`, and `boolean` are supported)
2. [Full JSON/OpenAPI schema for entities](https://github.com/strongloop/loopback-next/issues/5894),
including variants like with/without id, with/without relations, partial,
etc.
3. [Support for LoopBack-style filters](https://github.com/strongloop/loopback-next/issues/5895)
4. [JSON/OpenAPI schema to describe the supported filter format](https://github.com/strongloop/loopback-next/issues/5896)
5. [Custom repository classes](https://github.com/strongloop/loopback-next/issues/5897)
(e.g. to implement bookRepo.findByTitle(title)).
6. [Database migration](https://github.com/strongloop/loopback-next/issues/5898)

We will be implementing them progressively.

Expand Down
Loading

0 comments on commit dc00546

Please sign in to comment.