Strongloop Datasources

strongloop

How to add a new data-source?

slc loopback:datasource

How can we use Oracle database?

npm install loopback-connector-oracle

Run CLI to create new datasource:

$ slc loopback:datasource
[?] Enter the data-source name: oracledb
[?] Select the connector for oracledb: Oracle (supported by StrongLoop)

Edit /server/datasources.json and add your Oracle database login information:

 "oracledb": {
    "name": "oracledb",
    "connector": "oracle",
    "host": "demo.strongloop.com",
    "port": 1521,
    "database": "Sample",
    "username": "demo",
    "password": "secret"
}

How to add the MySQL connector?

npm install loopback-connector-mysql --save

Edit /server/datasources.json:

{
  "db": {
    "name": "db",
    "connector": "memory"
  },
  "mysqlDs": {
    "name": "mysqlDs",
    "connector": "mysql",
    "host": "demo.strongloop.com",
    "port": 3306,
    "database": "demo",
    "username": "demo",
    "password": "L00pBack"
  }
}

How to install Mongodb connector?

npm install --save loopback-connector-mongodb

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": "demo.strongloop.com",
    "port": 27017,
    "database": "getting_started_intermediate",
    "username": "demo",
    "password": "L00pBack"
  }

Does Strongloop support multiple data-sources?

Yes

Unless otherwise stated, the content of this page is licensed under Creative Commons Attribution-ShareAlike 3.0 License