Skip to content

Commit

Permalink
docs: removes required property itemType from the references many r…
Browse files Browse the repository at this point in the history
…elation decorator

Signed-off-by: Mike Evstropov <[email protected]>
  • Loading branch information
mikeevstropov committed Feb 24, 2022
1 parent b50e8fe commit f1575c2
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 19 deletions.
25 changes: 7 additions & 18 deletions docs/site/ReferencesMany-relation.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,11 @@ navigation APIs to deal with a graph of model instances. In addition to the
traditional ones, LoopBack supports `referencesMany` relation that embeds an
array of foreign keys to reference other objects. For example:

```ts
```json
{
id: 1,
name: 'John Smith',
accountIds: [
"saving-01", "checking-01",
]
"id": 1,
"name": "John Smith",
"accountIds": ["saving-01", "checking-01"]
}
```

Expand Down Expand Up @@ -107,7 +105,7 @@ export class Customer extends Entity {
})
name: string;

@referencesMany(() => Account, {}, {itemType: 'number'})
@referencesMany(() => Account)
accountIds: number[]; // relation name will default to `accounts`

constructor(data: Partial<Customer>) {
Expand Down Expand Up @@ -148,7 +146,6 @@ export class Customer extends Entity {
@referencesMany(
() => Account,
{name: 'accounts'}, // specify the relation name if fk is customized
{itemType: 'number'},
)
account_ids: number[]; // customized foreign keys

Expand All @@ -164,11 +161,7 @@ you to do so:
```ts
class Customer extends Entity {
// constructor, properties, etc.
@referencesMany(
() => Account,
{keyFrom: 'accountIds'},
{name: 'account_ids', itemType: 'number'},
)
@referencesMany(() => Account, {keyFrom: 'accountIds'}, {name: 'account_ids'})
accountIds: number[];
}
```
Expand All @@ -180,11 +173,7 @@ key of the target model (joining two tables on non-primary attribute), the
```ts
class Customer extends Entity {
// constructor, properties, etc.
@referencesMany(
() => Account,
{keyTo: 'customized_target_property'},
{itemType: 'number'},
)
@referencesMany(() => Account, {keyTo: 'customized_target_property'})
accountIds: number[];
}

Expand Down
2 changes: 1 addition & 1 deletion docs/site/decorators/Decorators_repository.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ import {Account} from './account.model';
export class Customer extends Entity {
// properties

@referencesMany(() => Account, {}, {itemType: 'number'})
@referencesMany(() => Account)
accountIds: number[];

// etc
Expand Down

0 comments on commit f1575c2

Please sign in to comment.