Search code examples
jquerycouchdbcouchdb-futon

is couchDB just not the right tool for large datasets?


I'm looking into couchDB. If i understand correctly, you can't just send a "query" to couchDB and do a partial update.

For example this document called "users" (simplified for clarity):

{
   allusers: [
      {"id": 1, "username":"myuser1", "pass":"secret"},
      {"id": 2, "username":"myuser2", "pass":"password"},
      {"id": 3, "username":"myuser3", "pass":"crypto"}
   ]
}

Is it true there isn't really a way to update user 3's password, that instead I have to load the entire document, make the update in javascript on the client, then send the whole object back using a PUT request?

I'm hoping that I just don't quite understand how couchDB works and wants things done.

How do I update one part of a possibly very large object?


Solution

  • Documents in a document store (like CouchDB is) are conceptually similar to rows in a RDBMS table or files in a filesystem, not tables.

    In your example, you'd have seperate documents for myuser1, one for myuser2, and one for myuser3, each of which would be small, self-contained and therefore easy and fast to update. Ideally, all of your documents would be like that.

    The CouchDB Guide has an excellent chapter on what CouchDB is and why (and when!) it's useful.