Looking at the example described in Adds a Douch Douch .
It discusses mapping views and how you can have one document for your blog posts, and then each comment is a separate document in CouchDB. So, for example, I could have “My post” and 5 comments related to “My post”, a total of 6 documents. In their example, “myslug” is stored both in the mail document and in each comment document, so when I search for CouchDB with the key “myslug”, it returns all documents.
Here is the problem / question. Let's say I want to search for the author in the comments and publication, which also has the category of "news." How will it work?
So for example:
function(doc) { if (doc.type == "post") { emit([doc._id, 0], doc); } else if (doc.type == "comment") { emit([doc.post, 1], doc); } }
This will load my blog post and comments based on this ?startkey=["myslug"]
However, I want to do this, grab the author’s comments from bob and a post that has category news. In this example, bob wrote three comments on a category news blog post. It seems that CouchDB allows me to search only the keys that exist in both documents, and not search by the key in one document and the key in another, which is “connected” with the card function.
In other words, if the message and comments are combined in slug, how can I search in one field in one document and in another field in another document, to which the identifier aka joins. bullets?
In SQL, it will be something like this:
SELECT * FROM comments JOIN doc.id ON doc.post WHERE author = bob AND category = news