incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Daniel Gonzalez <gonva...@gonvaled.com>
Subject Re: What would be the best way to exactly duplicate a document, with attachments?
Date Thu, 05 Dec 2013 07:46:07 GMT
Thanks,

That is interesting, but it will not allow me to copy to another
server/database.

I have remembered that I can get all attachments (no stubs) at once with
attachments=true, and that is exactly what I need.

BR,
Daniel


On Thu, Dec 5, 2013 at 8:25 AM, Garren Smith <garren@apache.org> wrote:

> Hi Daniel,
>
> You can use the copy API, that should duplicate the document for you. See
> the docs for more
> http://docs.couchdb.org/en/latest/api/document/common.html#copy--db-docid
>
> Cheers
> Garren
>
> On 05 December 2013 at 8:07:04 AM, Daniel Gonzalez (gonvaled@gonvaled.com<//gonvaled@gonvaled.com>)
> wrote:
>
> Hi all,
>
> Let's say I have host1/db1/doc_id1 which I want to duplicate to
> host2/db2/doc_id2.
>
> The original document has (maybe) attachments. Currently what I am doing
> is:
>
> 1.
> Get doc1. I get an attachment stub.
> 2.
> Put this document to host2/db2/doc_id2
> 3.
> Now I should loop through all attachments, get them, and put them to the
> new document. Probably something will not be guesses right (content_type,
> ...).
>
> Instead, I would like to use a method which:
>
> 1.
> Duplicates the document by using a single GET to obtain the original
> documents + attachments, and creates the new document with a single
> PUT/POST (is this possible, no matter the amount of attachments?)
> 2.
> Does not use the filesystem to save the attachments
> 3.
> Does not use replication
> 4.
> Does not recreate the attachments: specifically, no re-guessing of the
> content type and other attachment properties.
> To make it clear: I want an exact copy of the original document, except
> that:
>
> 1.
> The doc_id is different
> 2.
> It is in a different host/database than the original document
> 3.
> There is no revision
>
> Is there any built-in couchdb support for this?
>
> Thanks,
> Daniel
>
>
> Link to original SO question: http://stackoverflow.com/q/20386913/647991
>
>

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