Can t find value for key while using CouchDB for Fabric

0 votes
The following commands run just fine:

peer chaincode invoke -n mycc -c '{"Args":["set", "a", "20"]}' -C myc

peer chaincode query -n mycc -c '{"Args":["query","a"]}' -C myc

I am experimenting a little to understand the working of the tutorial and so have modified docker-compose-simple.yaml file as follows:

CORE_LEDGER_STATE_STATEDATABASE=CouchDB

CORE_LEDGER_STATE_COUCHDBCONFIG_COUCHDBADDRESS=couchdb0:5984

I have seen in the CouchDB documentation that we get the data like this:

{

  "total_rows": 3,

  "offset": 0,

  "rows": [{

      "id": "lscc\u0000mycc",

      "key": "lscc\u0000mycc",

      "value": {

        "rev": "1-dc6dc8ff92efd35358cf5b89e7949c25"

      }

    },

    {

      "id": "mycc\u0000a",

      "key": "mycc\u0000a",

      "value": {

        "rev": "3-7ad1349ec711a99a2a2f1dd1c8b08a20"

      }

    },

    {

      "id": "statedb_savepoint",

      "key": "statedb_savepoint",

      "value": {

        "rev": "6-2c3d131fc75772cc9e70311998bdde9d"

      }

    }

  ]

}

Now my question is, how to find the the value of key and where it is stored?
Jul 31, 2018 in Blockchain by digger
• 26,740 points

retagged Nov 23, 2018 by Kalgi 1,749 views

1 answer to this question.

0 votes

In the output you have mentioned:

{

  "id": "mycc\u0000a",

  "key": "mycc\u0000a",

  "value": {

    "rev": "3-7ad1349ec711a99a2a2f1dd1c8b08a20"

  }

},

The key is prefixed with the name of your chaincode i.e., key “a” for chaincode “mycc”. To get the value, all you have to do is run a curl command:

curl -X GET "http://localhost:5984/mychannel/mycc%00a?attachments=true"

you’ll get the output like this:

--bdb0a91d2e233fdc193f2359e6a50472

Content-Type: application/json

{"_id":"mycc\u0000a","_rev":"2-2af72e502c2b43c73064728852103fbf","chaincodeid":"mycc","version":"4:0","_attachments":{"valueBytes":{"content_type":"application/octet-stream","revpos":2,"digest":"md5-qpvq4/JGMCgu7WtvFu5zbg==","length":2,"follows":true,"encoding":"gzip","encoded_length":22}}}

--bdb0a91d2e233fdc193f2359e6a50472

Content-Disposition: attachment; filename="valueBytes"

Content-Type: application/octet-stream

Content-Length: 22

Content-Encoding: gzip

4鯄i

--bdb0a91d2e233fdc193f2359e6a50472--%

answered Jul 31, 2018 by slayer
• 29,370 points

Related Questions In Blockchain

+1 vote
2 answers
+1 vote
4 answers
0 votes
1 answer

Error while running make command using Fabric 1.0.6

It's a known issue in go 1.9.4: https://github.com/golang/go/issues/23739 While ...READ MORE

answered Jun 27, 2018 in Blockchain by Perry
• 17,100 points
1,095 views
0 votes
1 answer
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,470 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
1,947 views
0 votes
1 answer
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP