-
Notifications
You must be signed in to change notification settings - Fork 6
/
getBanks.js
31 lines (26 loc) · 883 Bytes
/
getBanks.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const BusinessNetworkConnection = require('composer-client').BusinessNetworkConnection
const Table = require('cli-table2')
const getBanks = (async function(){
try {
this.bizNetworkConnection = new BusinessNetworkConnection()
let connection = await this.bizNetworkConnection.connect('admin@land-registry')
let registry = await this.bizNetworkConnection.getParticipantRegistry('org.acme.landregistry.Bank')
let resources = await registry.getAll()
let table = new Table({
head: ['BankID', 'Name', 'Balance']
})
let arrayLength = resources.length
for(let i = 0; i < arrayLength; i++) {
let tableLine = []
tableLine.push(resources[i].id)
tableLine.push(resources[i].name)
tableLine.push(resources[i].balance)
table.push(tableLine)
}
console.log(table.toString())
process.exit()
} catch( err ){
console.log(err)
process.exit()
}
})()