blueFast
blueFast

Reputation: 44371

Using empty filter keys when accessing a view in a couchapp

It is possible to filter by keys when accessing a view from a couchapp application (see this question):

$.couch.db("MyDocuments").view("MyDesign/MyView", {
    success: function(data) {
        console.log(data);
    },
    error: function(status) {
        console.log(status);
    },
    key: ['Michael','2011-08-02'],
    reduce: false
});

Now, how would I use that key when I am only interested in one of the fields? (but the view is emitting both: the view is not changing)

I have tried:

    key: ['Michael',{}],

and

    key: ['Michael',''],

But none of them seem to work.

Upvotes: 1

Views: 204

Answers (1)

Robert Newson
Robert Newson

Reputation: 4631

try;

startkey: ['Michael'],
endkey: ['Michael',{}]

This will find all rows where the first element is 'Michael'.

This works because of the collation rules (detailed below) that dictate how array keys are ordered.

http://wiki.apache.org/couchdb/View_collation

Upvotes: 2

Related Questions