Reputation: 1222
{
"_id": "usq",
"_rev": "5-f8e9a8853b15f0270df94c1ae71323216",
"transactions": [
{
"admin_notification": [],
"admin_status": "pending",
"payment_amount_usd": "1",
"sp_tx_datetime": "Feb 26, 2021, 12:22 PM",
"sp_tx_hash": "pi_tx1",
"sp_tx_status": "succeeded",
"sp_tx_toAddress": "Admin",
"tx_admin_dateTime": "-",
"user_buyplan_days": "7 Days"
},
{
"admin_notification": [],
"admin_status": "pending",
"payment_amount_usd": "2",
"sp_tx_datetime": "Feb 26, 2021, 4:09 PM",
"sp_tx_hash": "pi_tx2",
"sp_tx_status": "succeeded",
"sp_tx_toAddress": "Admin",
"tx_admin_dateTime": "-",
"user_buyplan_days": "7 Days"
},
{
"admin_notification": [],
"admin_status": "pending",
"payment_amount_usd": "1",
"sp_tx_datetime": "Feb 26, 2021, 12:22 PM",
"sp_tx_hash": "pi_tx3",
"sp_tx_status": "succeeded",
"sp_tx_toAddress": "Admin",
"tx_admin_dateTime": "-",
"user_buyplan_days": "7 Days"
}
],
"user_email": "[email protected]",
"user_fName": "Sam",
"user_id": "user_2304354",
"user_lName": "Smith",
"user_password": "Abc@123456",
"user_type": "user",
"~version": "CgMBFgA="
}
Here I want only 2 transactions at the first time than the next ones. So I have used getQueryResultWithPagination methods But It doesn't work on a single object. So I created a view of CouchDB.
"views": {
"tx-view": {
"map": "function (doc) {if(doc.transactions.length > 0) { emit(doc.transactions); }}"
},
"tx-view-2": {
"map": "function (doc) { if(doc.transactions.length > 0) { doc.transactions.forEach(function (tag) { emit(doc.user_id, tag); });}}"
}
},
Can I add this view into chaincode query method and create a transaction for the same? How do I resolve this?
Upvotes: 0
Views: 288
Reputation: 124
Have you tried looking at this sample contract & application? https://github.com/hyperledger/fabric-samples/tree/master/asset-transfer-ledger-queries
Upvotes: 0