Skip to content

Commit

Permalink
chore: feedback
Browse files Browse the repository at this point in the history
Feedback 1
  • Loading branch information
Yaapa Hage committed Jun 3, 2020
1 parent dd4ead4 commit b7094b4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 10 deletions.
12 changes: 8 additions & 4 deletions docs/site/DataSources.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export class DbDataSource extends juggler.DataSource {

A datasource can be created at runtime by creating an instance of
`juggler.DataSource`. It requires a name for the datasource, the connector, and
a connection url as shown below.
the connection details.

```ts
import {juggler} from '@loopback/repository';
Expand All @@ -71,6 +71,10 @@ await bookDs.connect();
app.dataSource(bookDs, dsName);
```

To use the newly created datasource, call its `.connect()` method and attach it
to the app using `app.dataSource()` method. Note, this method will be available
only on `RepositoryMixin` apps.
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
with `RepositoryMixin` applied.
16 changes: 12 additions & 4 deletions docs/site/Model.md
Original file line number Diff line number Diff line change
Expand Up @@ -116,8 +116,9 @@ 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`), folowed by the model definition object as shown
in the example below.
(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.

```ts
const BookModel = defineModelClass<typeof Entity, {id: number; title?: string}>(
Expand All @@ -130,14 +131,21 @@ In case you need to use an existing Model as the base class, specify the Model
as the base class instead of `Entity`.

```ts
import DynamicModelCtor from '@loopback/repository';
// Assuming User is a pre-existing Model class in the app
import {User} from './user.model';
import DynamicModelCtor from '@loopback/repository';
const StudentModel = defineModelClass<
typeof User,
{id: number; university?: string}
// id being provided by the base class User
{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
`RepositoryMixin` applied.

## Model Discovery

LoopBack can automatically create model definitions by discovering the schema of
Expand Down
4 changes: 2 additions & 2 deletions docs/site/Repositories.md
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,8 @@ inject(`datasources.${dsName.name}`)(BookRepository, undefined, 0);
const repoBinding = app.repository(BookRepository);
```

Note, the `app.repository()` method will be available only on `RepositoryMixin`
apps
Note, the `app.repository()` method is available only on application classes
with `RepositoryMixin` applied.

## Access KeyValue Stores

Expand Down

0 comments on commit b7094b4

Please sign in to comment.