Thanks!   I extended it as you suggested to emit keys for all ancestors (and I 
changed from storing the materialized path in the id to storing it in a 
separate path field), so my map function is

function(doc) {
        var i;
        if (doc.work < 0 && doc.path.length >= 2) {
                emit(doc.path, false);
                for( i = 2; i < doc.path.length; ++i )
                        emit(doc.path.slice(0, i), true);
        }
}

and my reduce function is

function (keys, values, rereduce) {
        var hasUndoneDescendants = false;
        for (var i=0; i<keys.length; ++i) {
                if (values[i])
                        hasUndoneDescendants = true;
        }

        return hasUndoneDescendants;
}

Now it works as intended!

On Sep 28, 2010, at 1:03 PM, Dennis Clark wrote:

> function(doc) {
> if (doc.work < 0) {
>   emit(doc._id,[doc.work,0]);
>   emit(doc.parent._id,[doc.work,1]);
> }
> }

Doug Reeder
[email protected]
http://reeder29.livejournal.com/
https://twitter.com/reeder29

https://twitter.com/hominidsoftware
http://outlinetracker.com








Reply via email to