incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Nicholas Orr <nicholas....@zxgen.net>
Subject Re: best way to map this?
Date Thu, 09 Jul 2009 00:12:34 GMT
One thing you'd need to do is
for(project in doc.projects) {

}

right now looking at what your doing your asking for the projectid property
of an array, which isn't what you want...

I don't know about the other stuff, this is one thing I noticed.

Nick

On Thu, Jul 9, 2009 at 5:29 AM, Warner Onstine <warnero@gmail.com> wrote:

> Hi all, I'm fairly new to CouchDB and have been reading through the
> wiki and different articles online relating to this.
>
> I have two documents:
> - Project
> - User
>
> A project will have many users, and a user can belong to more than one
> project. Initially I set it up like this:
> Project
> - id = "project_[name]" (where name is below)
> - name = [name]
> - type = "project"
> etc.
>
> User
> - id = "[User's name]"
> - type = "user"
> - projects = [{"project_id" = "[a specific project]", "role" =
> "developer" (or something else)}, ...(other projects)]
>
> I then created a collation view (which I'm still playing with, having
> an issue with the multiple projects part for a developer):
> function(doc) {
>  if(doc.type == "project") {
>        emit([doc._id, 0], doc);
>  } else if (doc.type == "user") {
>        emit([doc.projects.project_id, 1], doc);
>  }
> }
>
> I've been looking at creating another document called project_users
> (rather a new type) that I can join on, but then read the entity
> relationship doc and it says it will require multiple queries to get
> all the data for this type of join.
>
> There does exist the possibility that a user will be updating their
> info while someone else is attempting to add them to a project (thus
> creating a conflict).
>
> Looking for others thoughts on this. Thanks!
>
> -warner
>

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