couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Javier Julio <>
Subject Query a view with id list but for one key
Date Tue, 08 Feb 2011 23:34:38 GMT
Hey all,

I've been reading on and using CouchDB since December last year. It's been
great and I've gotten my head around it quite well but on some harder tasks
I'm struggling a little. Let me talk about what I'm currently doing.

I'm using CouchDB for a social app where users can save places. The same
place can be stored in the db multiple times since its tied to a user. Each
place has a unique id. Since this is a social app, say if User A has various
friends and they have saved the same place, I'd like have a view where I can
get a list of those friends. Think like in Facebook when you have a comment
or status update and a bunch of people "like" it, you'd see something like
"You and 5 others like this". When you click on that link you'll get a list
of those people's names.

I can easily create a view that has a map function that just emits the
document id, place id, and user id. The problem I have figuring out is if I
have an id list of User A's friends how can I pass that into the view? From
what I know this doesn't seem like how it works. I'm most likely approaching
this wrong and thinking to much about how I would do this with SQL
(basically using a WHERE IN statement).

Any suggestions? While I just could have the view return all places saved by
anyone else but that seems excessive because there is definitely the
potential that many people have that place saved that aren't even that
users' friend.


Javier Julio
Senior Software Developer, 9mmedia

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