title | lang | layout | keywords | tags | sidebar | permalink | summary |
---|---|---|---|---|---|---|---|
Push connector |
ja |
page |
LoopBack |
connectors |
ja_lb3_sidebar |
/doc/ja/lb3/Push-connector.html |
If you haven't yet installed the Push component, in your application root directory, enter:
$ 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.
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):
{% include code-caption.html content="/server/datasources.json" %}
...
"myPushDataSource": {
"name": "myPushDataSource",
"connector": "push"
}
...
To configure a push data source, edit the datasources.json
file.
For example as shown in the push example:
{% include code-caption.html content="/server/datasources.json" %}
"myPushDataSource": {
"name": "myPushDataSource",
"connector": "push",
"installation": "installation",
"notification": "notification",
"application": "application"
}
}
Then define a push model in the Model definition JSON file, for example:
{% include code-caption.html content="/server/models/push.json" %}
{
"name": "push",
"base": "Model",
"plural": "Push",
"properties": {},
"validations": [],
"relations": {},
"acls": [],
"methods": []
}
Connect the model to the data source:
{% include code-caption.html content="/server/model-config.json" %}
"push": {
"public": true,
"dataSource": "myPushDataSource"
}