I have a sample document below:
{
companyId: 1,
productId: 2,
companyName: “ABC”,
productName: “XYZ”,
productType: “qwerty”,
epoch: 20150801,
location: “Mumbai”
}
The “epoch” value is an integer representing date. The view is created in design document named demo and view name demoView, in which the map function is:
function(doc, meta)
{
emit([ doc.epoch, doc.companyId, doc.productId ], doc]);
}
Using Node sdk, I want to write a query to retrieve all documents after a given date and which match a set of given companyId and productId combinations.
For example,
latestEpoch=request.payload.epoch
keyArray=[ [1,1], [1,2], [3,5], [2,6] ] // combination of Company Id and Product Id
var query = couchbase.ViewQuery.from(‘dev_demo’, ‘demoView’).range( [latestepoch,{},{}], [{},{},{}] ).keys(keyArray).limit(50);
Can I use range query on the first key element and .keys on the second and third elements?