Reputation: 17
I have couchdb setup to have documents like below
{
"_id": "id",
"_rev": "rev",
"docType": "CLAIM",
"createDate": 1633074806,
"customerClaimNumber": "CCN101",
"claimID": "CLID101"
}
Requirement is to have claims returned (claim id and customerclaim number) based on the createDate between start of day to end of day. CreateDate is epoch timestamp (an integer)
I have written the below view
function (doc) {
if(doc.docType =="CLAIM" && doc.claimDate && doc.customerClaimNumber) {
emit([doc.claimDate], doc.customerClaimNumber, doc.claimID);
}
}
I am looking at the recommendation to achieve search based on the createDate field (integer)
Upvotes: 0
Views: 51
Reputation: 17
Well eventually i got this done by creating the view as
function (doc) {
if(doc.docType =="CLAIM" && doc.claimDate && doc.customerClaimNumber) {
emit(doc.claimDate, {vendorClaimNumber: doc.customerClaimNumber, blockchainClaimID: doc.claimID});
}
}
and then calling the view
_view/viewname?startkey=1600000212&endkey=1600010212
Upvotes: 1