couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Mark Deibert <>
Subject Re: Design Question: What is a Good Model?
Date Thu, 10 Oct 2013 10:34:54 GMT
@Florian: It's not that simple. Pirate Ben's question was...

"But what is the best way to retrieve the "favorites" associated with
a specific

This will require 2 tables, perhaps 3. 2 if you go with the flatter
approach of putting the favorites in an array attrib in the user. 3 if you
want a favorites linking doc with user-2-event. I think it will be 2
queries to get "user's favorite events" info regardless of whether you do 2
or 3 docs. I think I'd opt for the 2 table version.

On Wed, Oct 9, 2013 at 8:03 PM, Filippo Fadda <> wrote:

> If you just want return the user favorites of course, you can just emit
> userId as key and eventId as value, but if you want show them ordered by
> timestamp (events belong in time), you must include the timestamp in the
> key: emit([userId, timestamp], eventId). That because in CouchDB the query
> results are _always_ ordered key.
> -Filippo
> On Oct 9, 2013, at 11:23 PM, Florian Westreicher Bakk.techn. wrote:
> > Quick question: why would a complex key be required? Could we not emit
> (userid, eventid) and be happy?

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