You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Paul Gross <pg...@gmail.com> on 2008/12/22 05:33:16 UTC
Migrating documents
I'm new to couchdb, and one idea I've been struggling with is how to
migrate data during a software upgrade. For example, say I start a
project and I have documents like:
{
"type": "person",
"name": "Joe Smith"
}
Now, with version 2.0 of my software, I want to split out name into
first_name and last_name:
{
"type": "person",
"first_name": "Joe",
"last_name": "Smith"
}
Or maybe I just want to rename an attribute (name => full_name).
What is the best way to migrate all of the existing documents? Is there
a way to do it server side, or do I have to read all of my documents and
bulk update them?
Thanks,
Paul Gross
http://www.pgrs.net
Re: Migrating documents
Posted by Chris Anderson <jc...@gmail.com>.
On Sun, Dec 21, 2008 at 8:33 PM, Paul Gross <pg...@gmail.com> wrote:
> What is the best way to migrate all of the existing documents? Is there a
> way to do it server side, or do I have to read all of my documents and bulk
> update them?
>
Iterating over the documents like that is probably the easiest way.
You can use _all_docs with ?include_docs=true for reading, and
_bulk_docs for updating. You could also use a view that pulls out only
the un-migrated documents, and query it to make sure you got all of
them (in case of old inserts during the upgrade, or something.)
--
Chris Anderson
http://jchris.mfdz.com