1

i'm trying to set up the Hyperledger Composer Rest Server (https://hyperledger.github.io/composer/reference/rest-server) in order to work with Cloudant DB on IBM Cloud and store inside it the cards used to interact with the blockchain.

In particular i would like to know how to configure the COMPOSER_DATASOURCES parameter of composer-rest-server.

Thanks in advance for your availability.
Best Regards

Leonardo Carraro
  • 1,532
  • 1
  • 11
  • 24

1 Answers1

1

The Composer Rest Server uses loopback, and so the COMPOSER_DATASOURCES are lookback datasources. In order to use cloudant you would need to use npm to install loopback-conector-cloudant, and then set the data source to be something like:

"mydb": {
  "name": "mydb",
  "connector": "cloudant",
  "username": "XXXX-bluemix",
  "password": "YYYYYYYYYYYY",
  "database": "test"
}

There is good detailed documentation here from loopback.

R Thatcher
  • 5,550
  • 1
  • 7
  • 15
  • Hey @R Thatcher, I'm trying to do this as well but when I do, it's storing the google authentication data in my database. Is it supposed to do this? I thought it was just storing the card credentials there so that they can persist. I'm also getting errors about the number of queries that are being made to the database (lite plan only allows 5 queries/sec) but I would of thought that was more than enough for just being a store of card credentials. I might be doing something wrong, but I just want to sanity check my assumptions before I go down the rabbit hole! – Simon Mullaney Jun 29 '18 at 14:00
  • If I do a `composer card list` in my terminal I can see the cards in my cloudant database. However if I do a http get method from my rest server it returns an empty array. – Simon Mullaney Jun 29 '18 at 14:03
  • My COMPOSER_DATASOURCES = {"db": { "name": "db", "connector": "cloudant", "username": "83bcdxxxxxxxxxxx4a9-bluemix", "password": "01exxxxxxxxxxxxxxxxxc85ab35ce9ba", "database": "wallet" } } For a database called wallet in cloudant. Inside the wallet database, there is a document called cards where the card details are stored. – Simon Mullaney Jun 29 '18 at 14:24