Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
97 commits
Select commit Hold shift + click to select a range
af1068f
feat: cli
Jan 8, 2019
0a4f195
feat(cli): add lb4 relation cli user input
SharonItz Jan 21, 2019
3231b29
feat(cli): adding lb4 relation cli model controller and repository files
SharonItz Jan 23, 2019
d6d5bef
feat(cli): run npm lint on lb4 relation new files
SharonItz Jan 23, 2019
e807c9d
fix(repository): test for commit
Jan 28, 2019
779f31d
CLI relation new feature issue #2223
Jan 28, 2019
f40ec99
CLI relation new feature issue #2223
Jan 28, 2019
8046de1
CLI relation new feature issue #2223
Jan 28, 2019
e0bbfde
feat(cli): add lb4 relation cli user input
SharonItz Jan 30, 2019
af6ae1e
Merge branch 'master' into add-lb4-relation
SharonItz Jan 30, 2019
dc16b01
Updated this.args and this.opts into relation cli.
oleg269 Jan 31, 2019
e6e7e4e
Fixed in controllerRelation sourceFile.
oleg269 Jan 31, 2019
d2055d0
Added to relation generator has many template.
oleg269 Jan 31, 2019
2880e95
Replaced relation type to constants.
oleg269 Feb 3, 2019
807c455
Model selection was moved to separate function.
oleg269 Feb 3, 2019
8469307
Code refactoring.
oleg269 Feb 3, 2019
1056a2f
feat(cli): added belongsto controller and belongsto template
The-Murdock Feb 4, 2019
4f3835f
docs(docs): initial documentation for the "lb4 relation" cli command
orshlom Feb 5, 2019
4771598
Fixed belongsTo controller.
oleg269 Feb 5, 2019
35d70e7
Fixed belongsTo controller.
oleg269 Feb 5, 2019
be05f01
Fixed has many controller tempalte.
oleg269 Feb 5, 2019
cdeb4f4
Code cleanup.
oleg269 Feb 5, 2019
d7ec612
Updated params to create relation controller.
oleg269 Feb 5, 2019
a377521
Updated script to add relation to model.
oleg269 Feb 6, 2019
549d13a
Added prompt relation name.
oleg269 Feb 6, 2019
aee980e
docs(docs): updated "lb4 relation" cli command documentation
orshlom Feb 6, 2019
89ea3bb
feat(cli): fix update hasMany and belongsto Models
The-Murdock Feb 6, 2019
e8a584f
Merge branch 'add-lb4-relation' of github.com:TomerSalton/loopback-ne…
The-Murdock Feb 6, 2019
670d13e
feat(cli): added support for hasOne in model
The-Murdock Feb 6, 2019
b3062e0
Fixed default relation name calculation.
oleg269 Feb 6, 2019
eee94f7
Code refactoring.
oleg269 Feb 6, 2019
a15c9cf
Added foreign key type calculation.
oleg269 Feb 6, 2019
fc9aaaf
Added foreignKeyType to controller.
oleg269 Feb 10, 2019
a914022
Updated belnogsto controller.
oleg269 Feb 10, 2019
4707ef0
Running lint:fix.
oleg269 Feb 10, 2019
19e31db
Updated repositoryRelation.js.
oleg269 Feb 10, 2019
ca04244
Running lint:fix.
oleg269 Feb 10, 2019
73e8325
Code refactoring.
oleg269 Feb 10, 2019
f56e58e
Code refactoring.
oleg269 Feb 10, 2019
b49c814
cli relation index.js: removed redundant code.
oleg269 Feb 10, 2019
3a62abe
feat(cli): replaced multiple properties with options
The-Murdock Feb 10, 2019
de49c11
Merge branch 'add-lb4-relation' of github.com:TomerSalton/loopback-ne…
The-Murdock Feb 10, 2019
e739fdb
fixed import
The-Murdock Feb 10, 2019
4654e28
Fixed belongsto controller.
oleg269 Feb 10, 2019
512e3c3
Running lint:fix.
oleg269 Feb 10, 2019
4f2016d
Removed RELATION_TYPE consts.
oleg269 Feb 10, 2019
6029440
Fixed hasmany controller template: create call.
oleg269 Feb 10, 2019
b5b7b18
Add comment.
oleg269 Feb 10, 2019
d92bac1
Merge branch 'add-lb4-relation' of github.com:TomerSalton/loopback-ne…
The-Murdock Feb 10, 2019
09afc5a
Fixed model to Foreign key
The-Murdock Feb 10, 2019
241877d
added a comment for additional work
The-Murdock Feb 10, 2019
668b7e9
Added prompt foreign key exist.
oleg269 Feb 11, 2019
27000ca
Relation: removed unused function.
oleg269 Feb 11, 2019
3fd09b8
create foreignKey in traget model if missing
The-Murdock Feb 11, 2019
3728edd
Merge branch 'add-lb4-relation' of github.com:TomerSalton/loopback-ne…
The-Murdock Feb 11, 2019
9fb6ac7
fixed hasMany Model
The-Murdock Feb 11, 2019
88a6426
Fixed relation controller templates.
oleg269 Feb 11, 2019
2809baa
Running lint:fix.
oleg269 Feb 11, 2019
d47d154
Merge branch 'master' into add-lb4-relation
oleg269 Feb 12, 2019
0d2112b
ControllerRelation class splited to separated classes per relation type.
oleg269 Feb 12, 2019
786da3c
relation.generateControllers call moved from switch.
oleg269 Feb 12, 2019
22f981b
ModelRelation class splited to diff classes.
oleg269 Feb 12, 2019
0ee0108
npm run lint:fix.
oleg269 Feb 12, 2019
909ab66
Remvoed function isClassExist from relationutils.
oleg269 Feb 12, 2019
26a7f2b
added keyTo to hasMany when using custom foreignkey
The-Murdock Feb 13, 2019
5fa6118
removed comments for adding keyTo
The-Murdock Feb 17, 2019
bd71349
cli relations: replaced param name: relationBaseClass => relationType.
oleg269 Feb 17, 2019
2795fa6
cli relations: replaced param name: modelNameList => parameter.
oleg269 Feb 17, 2019
848f774
cli relations: updated _calcSourceModelPrimaryKeyType.
oleg269 Feb 17, 2019
5976687
Added to generator relation setOptions.
oleg269 Feb 18, 2019
c32e0c3
Added src ERROR_NO_MODELS_FOUND to relation/index.js.
oleg269 Feb 18, 2019
d1f549e
Removed redundant option from class RelationGenerator.
oleg269 Feb 18, 2019
05cbb28
Removed unused variabled.
oleg269 Feb 18, 2019
f088782
Added options to relation generator.
oleg269 Feb 18, 2019
1d7e8b0
Fixed prompt relation type.
oleg269 Feb 18, 2019
7452ee5
Fixed sourceModel and destinationModel prompts.
oleg269 Feb 18, 2019
4cb18a1
Fixed relation name prompt.
oleg269 Feb 18, 2019
6372a3a
Code refactoring.
oleg269 Feb 18, 2019
5b6408b
Moved scaffold function to end of file.
oleg269 Feb 18, 2019
ef90b04
Code refactoring.
oleg269 Feb 18, 2019
4c6102d
Code cleanup.
oleg269 Feb 18, 2019
d1d76bb
tslint:fix.
oleg269 Feb 18, 2019
fcb260d
Removed scaffold function from RelationGenerator class.
oleg269 Feb 19, 2019
deca37a
Fixed debug string.
oleg269 Feb 19, 2019
f1140e8
Fixed error Incorrect Relation Type in relation/index.js:416:23.
oleg269 Feb 19, 2019
b34bd6c
removed validation sourceModel and destinationModel is the same.
oleg269 Feb 19, 2019
ada357e
Code refactoring.
oleg269 Feb 19, 2019
bc14a41
Code refactoring.
oleg269 Feb 19, 2019
7e824c7
Added validation is model exist.
oleg269 Feb 19, 2019
ff54feb
feat(cli): test for model relation
The-Murdock Feb 19, 2019
e443186
npm run lint:fix
oleg269 Feb 19, 2019
82f97c0
Merge branch 'master' into add-lb4-relation
oleg269 Feb 19, 2019
0a6f743
Removed repositoryRelation.js.
oleg269 Feb 19, 2019
d831b91
Added check import hasMany to test.
oleg269 Feb 19, 2019
539aa18
npm run lint:fix
oleg269 Feb 19, 2019
c535fa6
Added async/await to save module.
oleg269 Feb 19, 2019
2a5df70
Merge branch 'master' into add-lb4-relation
oleg269 Mar 5, 2019
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
72 changes: 72 additions & 0 deletions docs/site/Relation-generator.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
---
lang: en
title: 'Relation generator'
keywords: LoopBack 4.0, LoopBack 4
sidebar: lb4_sidebar
permalink: /doc/en/lb4/Relation-generator.html
---

{% include content/generator-create-app.html lang=page.lang %}

The models involved in the relation must exist before running this generator.

### Synopsis

Adds a new `Relation` between existing source and target models in a LoopBack
application.

```sh
lb4 relation [options] [<idProperty>]
```

### Options

TBD

### Arguments

`<idProperty>` - Name of the ID property that will be created in the source
model. If not provided, the tool will use `id` as the default name when it
prompts for the ID property name.

### Interactive Prompts

The tool will prompt you for:

- **Relation `type` between models.** _(relationBaseClass)_ Prompts a list of
available relations to choose from as the type of the relation between the
source model and the target model. Supported relation types:

- hasMany
- hasOne
- belongsTo

- **Name of the `source` model.** _(sourceModel)_ Prompts a list of available
models to choose from as the source model of the relation.

- **Name of the `target` model.** _(targetModel)_ Prompts a list of available
models to choose from as the target model of the relation. Note: The selected
`source` model will not appear in the `target` model list.

- **Name of the `ID property` in the source model.** _(Optional, default: `id`)_
Prompts for the ID property name (serves as the foreign key) in the source
model. Note: Leave blank to use the default.

- **Name for the `property relation` in the source model.** TBD

### Output

Once all the prompts have been answered, the CLI will do the following:

- Update source Model class as follows:
`/src/models/${sourceModel-Name}.model.ts`
- Update target Model class as follows:
`/src/models/${targetModel-Name}.model.ts`
- Update source Model Repository class as follows:
`/src/repositories/${sourceModel-Repository-Name}.repository.ts`
- Update target Model Repository class as follows:
`/src/repositories/${targetModel-Repository-Name}.repository.ts`
- Create a Controller for the new relation as follows:
`/src/controllers/{sourceModel}-{targetModel}.controller.ts`
- Update `/src/controllers/index.ts` to export the newly created Controller
class.
Loading