-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathgetREregistry.js
More file actions
34 lines (29 loc) · 1.03 KB
/
getREregistry.js
File metadata and controls
34 lines (29 loc) · 1.03 KB
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
32
33
34
const BusinessNetworkConnection = require('composer-client').BusinessNetworkConnection
const Table = require('cli-table2')
const getREregistry = (async function(){
try {
this.bizNetworkConnection = new BusinessNetworkConnection()
let connection = await this.bizNetworkConnection.connect('admin@land-registry')
let registry = await this.bizNetworkConnection.getAssetRegistry('org.acme.landregistry.RealEstate')
let resources = await registry.getAll()
let table = new Table({
head: ['TitleID', 'OwnerID', 'Square Meters', 'Price', 'Address']
})
let arrayLength = resources.length
for(let i = 0; i < arrayLength; i++) {
let tableLine = []
tableLine.push(resources[i].id)
tableLine.push(resources[i].owner.$identifier)
tableLine.push(resources[i].squareMeters)
tableLine.push(resources[i].price)
tableLine.push(resources[i].address)
table.push(tableLine)
}
console.log(table.toString())
process.exit()
} catch(error) {
console.log(error)
process.exit()
}
}())
module.exports = getREregistry