Installation

If you haven’t yet installed the Push component, in your application root directory, enter:

  1. $ npm install loopback-component-push --save

This will install the module from npm and add it as a dependency to the application’s package.json file.

Creating a push data source

Create a new push data source with the data source generator.

When prompted, select other as the connector.

At the prompt “Enter the connector name without the loopback-connector- prefix,” enter push.

This creates an entry in datasources.json like this (for example):

/server/datasources.json

  1. ...
  2. "myPushDataSource": {
  3. "name": "myPushDataSource",
  4. "connector": "push"
  5. }
  6. ...

Configuring a push data source

To configure a push data source, edit the datasources.json file.For example as shown in the push example:

/server/datasources.json

  1. "myPushDataSource": {
  2. "name": "myPushDataSource",
  3. "connector": "push",
  4. "installation": "installation",
  5. "notification": "notification",
  6. "application": "application"
  7. }
  8. }

Defining a push model

Then define a push model in the Model definition JSON file, for example:

/server/models/push.json

  1. {
  2. "name": "push",
  3. "base": "Model",
  4. "plural": "Push",
  5. "properties": {},
  6. "validations": [],
  7. "relations": {},
  8. "acls": [],
  9. "methods": []
  10. }

Connect model to push data source

Connect the model to the data source:

/server/model-config.json

  1. "push": {
  2. "public": true,
  3. "dataSource": "myPushDataSource"
  4. }

Tags: connectors