My goal is to create a view which I can query documents with a range of date.
For example, let’s say I want to query documents created from Jan 01, 2015 to Feb 15, 2015.
I ended up with two ways of creating view key for such filter.
First: Composite Keys
var key = dateToArray(created_at); // The key will look like...[2015,1,1] ... [2015,2,15] emit(key, null);
Second: Single String Key
var date = dateToArray(created_at); var year = date.getUTCFullYear(); var month = date.getUTCMonth(); var day = date.getUTCDate(); var key = ... // and create something like... ["20150101"] ... ["20150215"] ... emit(key, null);
Now, my question is that which way would be more efficient, with regard to how Couchbase indexing works, when querying documents with a range of date.
Any opinions and thoughts are welcome~:)