fabric-ca-kvs-mongo
mongodb kvs for fabric-sdk-node
Install
npm i fabric-ca-kvs-mongo
Config
- config your network definition to use mongodb credentialStore
client:
credentialStore:
url: "mongodb://localhost:27017"
dbname: "org1"
collectionName: "credential"
cryptoStore:
url: "mongodb://localhost:27017"
dbname: "org1"
collectionName: "crypto"
- config fabric-sdk-node to use fabric-ca-kvs-mongo
const Client = require('fabric-client');
Client.setConfigSetting('key-value-store', 'fabric-sdk-kvs-mongo');
const client = Client.loadFromConfig('<some-path-to-your-network.yaml>');
await client.initCredentialStores();
const user = await client.loadUserFromStateStore(username);
await client.setUserContext(user);
Check the credentials from mongodb
mongodb:
container_name: mongo
image: mongo
ports:
- 27017:27017
use mongo shell to see what is in the credentials store.
$ mongo
> show dbs;
...
org1 0.000GB
org2 0.000GB
> use org1;
switched to db org1
> show collections;
credential
crypto
> db.credential.find();
> db.crypto.find();