couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Warner Onstine <warn...@gmail.com>
Subject best way to map this?
Date Wed, 08 Jul 2009 19:29:46 GMT
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
View raw message