Skip to content

Commit

Permalink
chore: feedback 2
Browse files Browse the repository at this point in the history
Feedback
  • Loading branch information
Yaapa Hage committed Jun 4, 2020
1 parent 9320a18 commit 3f416ec
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 11 deletions.
9 changes: 6 additions & 3 deletions docs/site/DataSources.md
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,13 @@ await bookDs.connect();
app.dataSource(bookDs, dsName);
```

For details about datasource options, refer to the
[DataSource documentation])(https://apidocs.strongloop.com/loopback-datasource-juggler/#datasource)
For details about datasource options, refer to the [DataSource
documentation])(https://apidocs.strongloop.com/loopback-datasource-juggler/#datasource)
.

Attach the newly created datasource to the app by calling `app.dataSource()`.
Note, the `app.repository()` method is available only on application classes

{% include note.html content="
The `app.datasource()` method is available only on application classes
with `RepositoryMixin` applied.
" %}
19 changes: 12 additions & 7 deletions docs/site/Model.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,13 +117,15 @@ export class Customer {
Models can be created at runtime using the `defineModelClass()` helper function
from the `@loopback/repository` class. It expects a base model to extend
(typically `Model` or `Entity`), followed by a `ModelDefinition` object as shown
in the example below. The `ModelDefinition` object is an abstraction for
specifying the various attributes of a LoopBack model.
in the example below.

```ts
const bookDef = new ModelDefinition('Book')
.addProperty('id', {type: 'number', id: true})
.addProperty('title', {type: 'string'});
const BookModel = defineModelClass<typeof Entity, {id: number; title?: string}>(
Entity,
bookDef,
Entity, // Base model
bookDef, // ModelDefinition
);
```

Expand All @@ -137,14 +139,17 @@ import DynamicModelCtor from '@loopback/repository';
const StudentModel = defineModelClass<
typeof User,
// id being provided by the base class User
{university?: string},
{university?: string}
>(User, studentDef);
```

If you want make this new Model available from other parts of the app, you can
call `app.model(StudentModel)` to create a binding for it. Note, the
`app.model()` method is available only on application classes with
call `app.model(StudentModel)` to create a binding for it.

{% include note.html content="
The `app.model()` method is available only on application classes with
`RepositoryMixin` applied.
" %}

## Model Discovery

Expand Down
4 changes: 3 additions & 1 deletion docs/site/Repositories.md
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,10 @@ inject(`datasources.${dsName.name}`)(BookRepository, undefined, 0);
const repoBinding = app.repository(BookRepository);
```

Note, the `app.repository()` method is available only on application classes
{% include note.html content="
The `app.repository()` method is available only on application classes
with `RepositoryMixin` applied.
" %}

## Access KeyValue Stores

Expand Down

0 comments on commit 3f416ec

Please sign in to comment.