I have couchbase documents in following format
{
"docType": "scheduledJob",
"orgId": 2,
"jobs": {
"1456753078157": {
"jobName": "Job1",
"jobId": "910271049",
"fromTime": 1456752600000,
"toTime": 1456824600000,
"key": 1456753141401,
"status": "pending"
},
"1456753141401": {
"jobName": "Job2",
"jobId": "558624841",
"fromTime": 1456752600000,
"toTime": 1456821000000,
"key": 1456753141401,
"status": "pending"
}
}
}
Which have jobs scheduled. The jobs can be executed anytime which falls between fromTime and toTime. My task is to check every hour if there is any job pending for coming hour. Means the whatever the fromTime is but toTime timestamp should be greater than timestamp of 1 hour after current time. Similarly we should fetch if the fromTime is also falls from current timestamp to next hour time stamp.
I am new to couchbase. The view I have created is
function(doc, meta){
if( doc.docType && doc.docType=="scheduledJob"){
for(var key in doc.jobs){
var job = doc.jobs[key]
if(job.status == "pending") {
emit(job.fromTime+'_'+job.toTime, job);
}
}
}
}
I am sending startkey="currentTimestamp_0000000000000" and endkey="0000000000000_currentTime+1hour-timestamp"
Please help me where I am going wrong.