incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alan Boyce <a...@alanboyce.com>
Subject Re: Map function to find docs in time interval
Date Mon, 19 Apr 2010 12:41:52 GMT
Hi,

Use epochs. Since they are seconds since 1970 they will sorty nicely.

var startTime = startDate.getTime()/1000.0;
var endTime = endDate.getTime()/1000.0;
emit([startTime, endTime]);


best,

alan

On Mon, 19 Apr 2010, Manokaran K wrote:

> On Mon, Apr 19, 2010 at 4:58 PM, Manokaran K <manokaran@gmail.com> wrote:
>
>> Following will create a lot of rows but the key size would be small:
>>
>> from_time = x milliseconds
>> till_time = y milliseconds
>>
>> for(var i=from_time; i<=till_time; i += 60000){ //for each visitor, a row
>> for every minute he/she was inside.
>>  emit(i, doc._id);
>> }
>>
>> Then you can query with the time (in millisecs) as the key to get all
>> visitors.
>>
>
>
> Sorry. Instead of key, you'll have to use startkey and endkey
>
> regds,
> mano
>

Mime
View raw message