couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paul Davis <paul.joseph.da...@gmail.com>
Subject Re: view key boolean operator
Date Sat, 31 Oct 2009 23:41:42 GMT
Norman,

Your best bet would be to emit something that flags that the property
doesn't exist. Perhaps something like:

emit(doc.a || null, null)

And then query for key=null

Granted that munges when doc.a is null. To be complete you'd need to
do something like:

if(doc.a !== undefined) {
    emit([doc.a], null):
} else {
    emit(null, null);
}

HTH,
Paul Davis

On Sat, Oct 31, 2009 at 6:21 PM, Norman Barker <norman.barker@gmail.com> wrote:
> Hi,
>
> is there a way to specify a key for a view such that the view returns
> all results that don't have that key?
>
> e.g. myview?key="~a", returns all documents with keys equal to b, c, d, ...
>
> I appreciate that I could get all document ids and then query for all
> documents with key 'a' and then return the difference but then I lose
> the advantage of being able to page the result.
>
> Has anyone tried this?
>
> thanks,
>
> Norman
>

Mime
View raw message