Skip to content

Repairing anchors #43

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 8, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion pages/en/lb2/Connect-your-API-to-a-data-source.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ Now add the loopback-connector-mysql module and install the dependencies:
{% include important.html content="
If you have a MySQL database server that you can use, please use it. Create a new database called \"getting_started.\" If you wish, you can use a different database name. Just make sure the `mysqlDs.database` property in `datasources.json `matches it (see below).

If not, you can use the StrongLoop MySQL server running on [demo.strongloop.com](http://demo.strongloop.com/). However, be aware that it is a shared resource. There is a small chance that two users may run the script that creates sample data (see [Add some test data and view it](/doc/en/lb2/Connect-your-API-to-a-data-source.html), below) at the same time and may run into race condition. For this reason, we recommend you use your own MySQL server if you have one." %}
If not, you can use the StrongLoop MySQL server running on [demo.strongloop.com](http://demo.strongloop.com/). However, be aware that it is a shared resource. There is a small chance that two users may run the script that creates sample data (see [Add some test data and view it](#add-some-test-data-and-view-it), below) at the same time and may run into race condition. For this reason, we recommend you use your own MySQL server if you have one." %}

Next, you need configure the data source to use the desired MySQL server.

Expand Down
2 changes: 1 addition & 1 deletion pages/en/lb2/Connecting-models-to-data-sources.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ To connect a model to a data source, follow these steps:
$ npm install --save loopback-connector-mysql
```

See [Connectors](/doc/{{page.lang}}/lb2/Connecting-models-to-data-sources.html) for the list of connectors.
See [Connectors](#connectors) for the list of connectors.

4. Use the [model generator](/doc/{{page.lang}}/lb2/Using-the-model-generator.html) to create a model.

Expand Down
6 changes: 3 additions & 3 deletions pages/en/lb2/Create-AngularJS-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ The other lines define application states.  _States_ determine which pages appe

The following table summarizes the states, and how the correspond to controllers, templates, and URLs.

<table>
<table id="state-summary">
<tbody>
<tr>
<th>State</th>
Expand Down Expand Up @@ -570,7 +570,7 @@ Angular _services_ are substitutable objects that you connect  together using 

The `js/services` directory contains two AngularJS services libraries: `auth.js` and `lb-services.js`.

You generated the l`b-services.js` previously, and it's described in [Generate lb-services.js](/doc/{{page.lang}}/lb2/Create-AngularJS-client.html). 
You generated the l`b-services.js` previously, and it's described in [Generate lb-services.js](#generate-lb-servicesjs). 

The other file, `auth.js`, provides a simple interface for low-level authentication mechanisms.  It uses the `Reviewer` model (that extends the base `User` model) and defines the following services:

Expand Down Expand Up @@ -630,7 +630,7 @@ angular

The `client/views` directory contains seven "partial" view templates loaded by `client/index.html` using the [ngView](https://docs.angularjs.org/api/ngRoute/directive/ngView) directive  A "partial" is a segment of a template in its own HTML file. 

The [table above](/doc/{{page.lang}}/lb2/Create-AngularJS-client.html) describes how the views correspond to states and controllers.
The [table above](#state-summary) describes how the views correspond to states and controllers.

## Run the application

Expand Down
6 changes: 3 additions & 3 deletions pages/en/lb2/Creating-a-database-schema-from-models.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@ Auto-migration creates tables for all models attached to a data source, includin
Once you have defined a model, LoopBack can create or update (synchronize) the database schemas accordingly, if you need to adjust the database to match the models.
LoopBack provides two ways to synchronize model definitions with table schemas:

* **[Auto-migrate](/doc/{{page.lang}}/lb2/Creating-a-database-schema-from-models.html)**: Automatically create or re-create the table schemas based on the model definitions. 
* **[Auto-update](/doc/{{page.lang}}/lb2/Creating-a-database-schema-from-models.html)**: Automatically alter the table schemas based on the model definitions.
* **[Auto-migrate](#auto-migrate)**: Automatically create or re-create the table schemas based on the model definitions. 
* **[Auto-update](#auto-update)**: Automatically alter the table schemas based on the model definitions.

{% include warning.html content="
Auto-migration will drop an existing table if its name matches a model name.
When tables with data exist, use [auto-update](Creating-a-database-schema-from-models.html) to avoid data loss.
When tables with data exist, use [auto-update](#auto-update) to avoid data loss.
" %}

## Auto-migrate
Expand Down
2 changes: 1 addition & 1 deletion pages/en/lb2/Defining-boot-scripts.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ Use _boot scripts_ to perform custom initialization in addition to that perfor
When an application starts, LoopBack loads all the scripts in the `server/boot` directory.
By default, LoopBack loads boot scripts in alphabetical order.
You can customize the boot script load order using the options argument of [`boot()`](http://apidocs.strongloop.com/loopback-boot/#boot).
See [Boot script loading order](/doc/{{page.lang}}/lb2/Defining-boot-scripts.html) for details.
See [Boot script loading order](#boot-script-loading-order) for details.

## Predefined boot scripts

Expand Down
47 changes: 23 additions & 24 deletions pages/en/lb2/Defining-middleware.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,29 +23,29 @@ Using phases helps to avoid ordering issues that can occur with standard Express

LoopBack supports the following types of middleware:

* **Pre-processing middleware** for custom application logic. See [example of static middleware](/doc/{{page.lang}}/lb2/Defining-middleware.html). 
* **Pre-processing middleware** for custom application logic. See [example of static middleware](#static-middleware). 
* **Dynamic request handling middleware** to serve dynamically-generated responses, for example HTML pages rendered from templates and JSON responses to REST API requests.
See [example of pre-processing middleware](/doc/{{page.lang}}/lb2/Defining-middleware.html).
* **Static middleware** to serve static client-side assets.  See [example of static middleware](/doc/{{page.lang}}/lb2/Defining-middleware.html).
* **Error-handling middleware** to deal with request errors. See [example of error-handling middleware](/doc/{{page.lang}}/lb2/Defining-middleware.html).
See [example of pre-processing middleware](#pre-processing-middleware).
* **Static middleware** to serve static client-side assets.  See [example of static middleware](#static-middleware).
* **Error-handling middleware** to deal with request errors. See [example of error-handling middleware](#error-handling-middleware).

### How to add middleware

To add middleware to your application:

1. **Specify the middleware function**:
1. If using an existing function or package, add the code to your application or install the package. 
2. If you are creating a new middleware function, write it. See [Defining a new middleware handler function](/doc/{{page.lang}}/lb2/Defining-middleware.html).
2. If you are creating a new middleware function, write it. See [Defining a new middleware handler function](#defining-a-new-middleware-handler-function).

2. **Register the middleware**:
* Edit `server/middleware.json`. This is the recommended way to register middleware. See [Registering middleware in middleware.json](/doc/{{page.lang}}/lb2/Defining-middleware.html).
* Alternatively, register the middleware in application code. See [Registering middleware in JavaScript](/doc/{{page.lang}}/lb2/Defining-middleware.html).
* Edit `server/middleware.json`. This is the recommended way to register middleware. See [Registering middleware in middleware.json](#registering-middleware-in-middlewarejson).
* Alternatively, register the middleware in application code. See [Registering middleware in JavaScript](#registering-middleware-in-javascript).

### Middleware phases

LoopBack defines a number of _phases_, corresponding to different aspects of application execution.
When you register middleware, you can specify the phase in which the application will call it.
See [Registering middleware in middleware.json](/doc/{{page.lang}}/lb2/Defining-middleware.html) and [Using the LoopBack API](/doc/{{page.lang}}/lb2/Defining-middleware.html).
See [Registering middleware in middleware.json](#registering-middleware-in-middlewarejson) and [Using the LoopBack API](#using-the-loopback-api).
If you register middleware (or routes) with the Express API, then it is executed at the beginning of the `routes` phase.

The predefined phases are:
Expand Down Expand Up @@ -79,7 +79,7 @@ Always explicitly order the middleware using appropriate phases when order matte
LoopBack provides convenience middleware for commonly-used Express/Connect middleware, as described in the following table.

When you use this middleware, you don't have to write any code or install any packages; you just specify in which phase you want it to be called.
See [Registering middleware in middleware.json](/doc/{{page.lang}}/lb2/Defining-middleware.html).
See [Registering middleware in middleware.json](#registering-middleware-in-middlewarejson).

<table>
<thead>
Expand Down Expand Up @@ -193,12 +193,11 @@ Best practice is to load this middleware directly via `require()` and not rely
</tr>
</tbody>
</table>
</div>&nbsp;
<p></p>
<div>
<h3 class="confluenceTable" id="Definingmiddleware-Usingothermiddleware">Using other middleware</h3></div>
</div>
</div>

### Using other middleware

You can use any middleware compatible with Express; see [Express documentation](http://expressjs.com/resources/middleware.html) for a partial list.

Simply install it:
Expand All @@ -208,9 +207,9 @@ $ npm install --save <module-name>
```

Then simply register it so that it is called as needed.
See [Registering middleware in middleware.json](/doc/{{page.lang}}/lb2/Defining-middleware.html
See [Registering middleware in middleware.json](#registering-middleware-in-middlewarejson
and
[Registering middleware in JavaScript](/doc/{{page.lang}}/lb2/Defining-middleware.html).
[Registering middleware in JavaScript](#registering-middleware-in-javascript).

### Defining a new middleware handler function

Expand Down Expand Up @@ -317,7 +316,7 @@ module.exports = function(options) {
};
```

For details about the `options` object, refer to [Middleware configuration properties](/doc/{{page.lang}}/lb2/Defining-middleware.html).
For details about the `options` object, refer to [Middleware configuration properties](#middleware-configuration-properties).

## Registering middleware in middleware.json

Expand Down Expand Up @@ -373,11 +372,11 @@ phase[:sub-phase] : {

Where:

* _phase_:  is one of the predefined phases listed above (initial, session, auth, and so on) or a custom phase; see [Adding a custom phase](/doc/{{page.lang}}/lb2/Defining-middleware.html).
* _phase_:  is one of the predefined phases listed above (initial, session, auth, and so on) or a custom phase; see [Adding a custom phase](#adding-a-custom-phase).
* _sub-phase_:  (optional) can be `before` or `after`.
* _name_: optional middleware name. See [Middleware configuration properties](/doc/{{page.lang}}/lb2/Defining-middleware.html) below.
* _middlewarePath_: path to the middleware function. See [Path to middleware function](/doc/{{page.lang}}/lb2/Defining-middleware.html) below.
* _paramSpec_:  value of the middleware parameters, typically a JSON object. See [Middleware configuration properties](/doc/{{page.lang}}/lb2/Defining-middleware.html) below.
* _name_: optional middleware name. See [Middleware configuration properties](#middleware-configuration-properties) below.
* _middlewarePath_: path to the middleware function. See [Path to middleware function](#path-to-middleware-function) below.
* _paramSpec_:  value of the middleware parameters, typically a JSON object. See [Middleware configuration properties](#middleware-configuration-properties) below.
* _methodSpec_: HTTP methods, such as 'GET', 'POST', and 'PUT'. If not present, applies to all methods.
* _routeSpec_:  REST endpoint(s) that trigger the middleware.

Expand All @@ -386,7 +385,7 @@ Where:
Specify the path to the middleware function (_middlewarePath)_ in the following ways:

* For an external middleware module installed in the project, just use the name of the module; for example `compression`.
See [Using other middleware](/doc/{{page.lang}}/lb2/Defining-middleware.html).
See [Using other middleware](#using-other-middleware).
* For a script in a module installed in the project, use the path to the module; for example `loopback/server/middleware/rest`.
* For a script with a custom middleware function, use the path relative to `middleware.json`, for example `./middleware/custom`.
* Absolute path to the script file (not recommended).
Expand Down Expand Up @@ -626,9 +625,9 @@ The parameters are:

1. _`route`_, an optional parameter that specifies the URI route or "mount path" to which the middleware is bound.
When the application receives an HTTP request at this route, it calls (or _triggers_) the handler function.
See [Specifying routes](/doc/{{page.lang}}/lb2/Defining-middleware.html).
See [Specifying routes](#specifying-routes).
2. The middleware handler function (or just "middleware function").
See [Defining a new middleware handler function](/doc/{{page.lang}}/lb2/Defining-middleware.html).
See [Defining a new middleware handler function](#defining-a-new-middleware-handler-function).

For example:

Expand Down Expand Up @@ -840,4 +839,4 @@ To register this middleware:
```

3. Start the application.
4. Load [http://localhost:3000/url-does-not-exist](http://localhost:3000/url-does-not-exist) in your browser.
4. Load [http://localhost:3000/url-does-not-exist](http://localhost:3000/url-does-not-exist) in your browser.
8 changes: 4 additions & 4 deletions pages/en/lb2/Embedded-models-and-relations.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ summary:
LoopBack relations enable you to create connections between models and provide navigation/aggregation APIs to deal with a graph of model instances.
In addition to the traditional ones, LoopBack also supports the following embedded relations:

* [EmbedsOne](/doc/{{page.lang}}/lb2/Embedded-models-and-relations.html) - a model that embeds another model; for example, a Customer embeds one billingAddress.
* [EmbedsMany](/doc/{{page.lang}}/lb2/Embedded-models-and-relations.html) - a model that embeds many instances of another model.
* [EmbedsOne](#embedsone) - a model that embeds another model; for example, a Customer embeds one billingAddress.
* [EmbedsMany](#embedsmany) - a model that embeds many instances of another model.
For example, a Customer can have multiple email addresses and each email address is a complex object that contains label and address..
* [EmbedsMany with belongsTo](/doc/{{page.lang}}/lb2/Embedded-models-and-relations.html) - a model that embeds many links to related people, such as an author or a reader. 
* [ReferencesMany](/doc/{{page.lang}}/lb2/Embedded-models-and-relations.html)
* [EmbedsMany with belongsTo](#embedsmany-with-belongsto) - a model that embeds many links to related people, such as an author or a reader. 
* [ReferencesMany](#referencesmany)

{% include important.html content="

Expand Down
2 changes: 1 addition & 1 deletion pages/en/lb2/Installing-compiler-tools.md
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ Enter the following command to validate your Xcode license, then reinstall Stron

Many Linux systems come with the necessary tools.   The specific requirements are:

* Python (v2.7 recommended; v3.x.x is **_not_** supported).  If you installed Python in a non-standard location, see [Configuring Python directory](/doc/{{page.lang}}/lb2/Installing-compiler-tools.html).
* Python (v2.7 recommended; v3.x.x is **_not_** supported).  If you installed Python in a non-standard location, see [Configuring Python directory](#configuring-python-directory).
* `make`
* A proper C/C-- compiler toolchain, like GCC.  **NOTE**: g-- version 4.2 or later is required.

Expand Down
2 changes: 1 addition & 1 deletion pages/en/lb2/Memory-connector.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ The memory connector supports:
{% include important.html content="
The memory connector is designed for development and testing of a single-process application without setting up a database. It cannot be used in a cluster as the worker processes will have their own isolated data not shared in the cluster.

You can persist data between application restarts using the `file` property. See [Data persistence](Memory-connector.html) for more information.
You can persist data between application restarts using the `file` property. See [Data persistence](#data-persistence) for more information.
" %}

## Creating a data source
Expand Down
2 changes: 1 addition & 1 deletion pages/en/lb2/Model-definition-JSON-file.md
Original file line number Diff line number Diff line change
Expand Up @@ -930,7 +930,7 @@ Product.find({order: "name", offset: 0, limit: 100, where: {deleted: false}}, cb

### Default scopes with where filters

Adding a `scope` to a model definition (in the [`model.json` file](/doc/{{page.lang}}/lb2/Model-definition-JSON-file.html)) automatically adds a method to model called `defaultScope()`.
Adding a `scope` to a model definition (in the model.json file) automatically adds a method to model called `defaultScope()`.
LoopBack will call this method whenever a model is created, updated, or queried.

{% include tip.html content="Default scopes with a `where` filter may not work as you expect!" %}
Expand Down
4 changes: 2 additions & 2 deletions pages/en/lb2/Operation-hooks.md
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ See the documentation of individual hooks for more information.

{% include important.html content="
Only certain connectors support `ctx.isNewInstance`. With other connectors it is undefined.
See [Checking for support of ctx.isNewInstance](Operation-hooks.html)." %}
See [Checking for support of ctx.isNewInstance](#checking-for-support-ofctxisnewinstance)." %}

##### currentInstance

Expand Down Expand Up @@ -475,7 +475,7 @@ Depending on which method triggered this hook, the context will have one of the
* `Model` - the constructor of the model that will be saved
* `where` - the where filter describing which instances will be affected
* `data` - the (partial) data to apply during the update
* `currentInstance` - the instance being affected, see [Triggering with prototype.updateAttributes](/doc/{{page.lang}}/lb2/Operation-hooks.html) below.
* `currentInstance` - the instance being affected, see [Triggering with prototype.updateAttributes](#triggering-with-prototypeupdateattributes) below.

#### ctx.isNewInstance

Expand Down
6 changes: 3 additions & 3 deletions pages/en/lb2/Push-notifications-for-Android-apps.md
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ Then follow these steps to run the app:

5. Edit `src/com/google/android/gcm/demo/app/DemoActivity.java`. 
* Set SENDER_ID to the project number from the Google Developers Console you created earlier in 
[Get your Google Cloud Messaging credentials](/doc/{{page.lang}}/lb2/Push-notifications-for-Android-apps.html).
[Get your Google Cloud Messaging credentials](#get-your-google-cloud-messaging-credentials).

6. Go back to the [https://cloud.google.com/console/project](https://cloud.google.com/console/project) and edit the Android Key to reflect
your unique application ID. Set the value of **Android applications** to something like this:
Expand Down Expand Up @@ -205,7 +205,7 @@ Add the following key and value to the push settings of your application:
}
```

Replace `server-api-key` with the API key you obtained in [Get your Google Cloud Messaging credentials](/doc/{{page.lang}}/lb2/Push-notifications-for-Android-apps.html).
Replace `server-api-key` with the API key you obtained in [Get your Google Cloud Messaging credentials](#get-your-google-cloud-messaging-credentials).

## Prepare your own Android project

Expand Down Expand Up @@ -368,4 +368,4 @@ When running your app in the Eclipse device emulator, you may encounter the foll
`Google Play services, which some of your applications rely on, is not supported by your device. Please contact the manufacturer for assistance.`

To resolve this, install a compatible version of the Google APIs platform.
See [Prepare your Android project](/doc/{{page.lang}}/lb2/Push-notifications-for-Android-apps.html) for more information.
See [Prepare your Android project](#prepare-your-own-android-project) for more information.
Loading