Installation
shell
$ npm install loopback-connector-redis --save
This will install the module and add it as a dependency to the application's package.json
file.
Creating a Redis data source
Use the data source generator to add a Redis data source to your application. When prompted for the connector, choose other, then enter redis for the connector name. The entry in the application's server/datasources.json
will look like this:
/server/datasources.json
"redisDS": { "name": "redisDS", "connector": "redis", }
Edit datasources.json
to add other properties that enable you to connect the data source to a Redis database.
Properties
Property | Type | Description |
---|---|---|
connector | String | Connector name, either "loopback-connector-redis" or "redis" |
database | String | Database name |
host | String | Database host name |
password | String | Password to connect to database |
port | Number | Database TCP port |
url | String | Use instead host and port properties. |
username | String | Username to connect to database |