incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dean Landolt" <>
Subject Re: when to use another document and when not to?
Date Mon, 21 Jul 2008 03:56:47 GMT
> Or, obviously, I would be delighted if someone could show me how I'm
> completely wrong and it is actually possible to do this : )

You can. Complex keys. I put together a little test:

The map function just uses a two-level key...

function(doc) {
  if (doc.type == 'user') {
    emit([doc.username,0], doc)
  } else if (doc.type == 'subscription') {
    emit([doc.follower, doc.followee], doc)

Read this for more details:

But yes, you can do joins. You can query this view for just one user simply:[%22dlandolt%22]&endkey=[%22dlandolt%22,{}]

Notice the {} in there -- from what I gather objects are at the bottom of
the sort, so this query gets all data related to user dlandolt -- the first
result (or any result with the second part of a key ending in 0 based on how
I wrote my view), and then everything following are the *subscription* docs
that Damien recommended.

Hope that helps.

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message