0

I'm fairly new to the world of CouchDB and just learned about the neat world of views. I did a bit of reading, but I'm not certain on how it works yet. My question is how could I query all the documents in a database for a matched value? I want to search a bunch of documents containing an object called username and only return the IDs of the documents that contain that...

How could I do this?

1 Answer 1

2

Should be a straight-forward map function, unless I'm misunderstanding or missing something.

function (doc) {
    if (doc.username) {
        emit(doc.username);
    }
}

The document _id will be a part of your view results already, so you can just emit the username by itself. If you add include_docs=true to your querystring, you can get the entire document as well.

Sign up to request clarification or add additional context in comments.

1 Comment

That's it? Wow, couchDB impresses like always!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.