You can easily connect a LoopBack application to multiple different data sources.
Page Contents

Add a data source

You’re going to add a MongoDB data source in addition to the MySQL data source created in Connect your API to a data source.

$ lb datasource

When prompted, respond as follows:

? Enter the data-source name: mongoDs
? Select the connector for mongoDs: MongoDB (supported by StrongLoop)

Install MongoDB connector

$ npm install --save loopback-connector-mongodb

Configure data source

Edit datasources.json to configure the data source so that it connects to the StrongLoop demo MongoDB server.  Add the following JSON after the two existing data source definitions (for “db” and “mysqlDs”):


"mongoDs": {
  "name": "mongoDs",
  "connector": "mongodb",
  "host": "",
  "port": 27017,
  "database": "getting_started_intermediate",
  "username": "demo",
  "password": "L00pBack"

Next: Continue to Create new models.