From b7094b47c3ffd3796c604d117433549110afd422 Mon Sep 17 00:00:00 2001 From: Yaapa Hage Date: Wed, 3 Jun 2020 21:57:40 +0530 Subject: [PATCH] chore: feedback Feedback 1 --- docs/site/DataSources.md | 12 ++++++++---- docs/site/Model.md | 16 ++++++++++++---- docs/site/Repositories.md | 4 ++-- 3 files changed, 22 insertions(+), 10 deletions(-) diff --git a/docs/site/DataSources.md b/docs/site/DataSources.md index 727ddd0da90f..35aa66fe3275 100644 --- a/docs/site/DataSources.md +++ b/docs/site/DataSources.md @@ -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'; @@ -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. diff --git a/docs/site/Model.md b/docs/site/Model.md index 2ed4fafe2d3c..9274e3fe2c5e 100644 --- a/docs/site/Model.md +++ b/docs/site/Model.md @@ -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( @@ -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 diff --git a/docs/site/Repositories.md b/docs/site/Repositories.md index 58c3df01c7da..7f0332e53e37 100644 --- a/docs/site/Repositories.md +++ b/docs/site/Repositories.md @@ -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