incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Robert Newson <robert.new...@gmail.com>
Subject Re: Atomic update of multiple attachments?
Date Tue, 08 Feb 2011 00:01:22 GMT
You could also use the COPY feature. :)

On Mon, Feb 7, 2011 at 11:59 PM, Wayne Conrad <wayne@databill.com> wrote:
> Bob, One of my needs is that requestors can get the most recent "complete"
> set of attachments, even while a new set is being assembled.  I've no sense
> of what it takes to work with previous version of a document, esp. since (as
> I understand it) replication doesn't transfer old revisions of documents.
>  Do you think your idea can be made to work with this need?
>
> I'm wondering if something can be done that's similar to how we
> create/rename files in Unix.  Can I create a temporary document, load it up
> with attachments, and then rename it?
>
> Wayne
>
> On 02/07/11 16:38, Robert Johnson wrote:
>>
>> Create your document with attributes "eventual_attachment _count" (set
>> this to the expected count) and "attachment_count_so_far" (set this to
>> zero).
>> As you add each attachment, increment "attachment_count_so_far"
>>
>> Create a view which only emits when "attachment_count_so_far" =
>> "eventual_attachment _count"
>>
>>
>> For update:-
>>
>> Remove docs and decrement "attachment_count_so_far"
>> Reset "eventual_attachment _count"if necessary
>> Add new attachments and increment "attachment_count_so_far"
>>
>> Does this work for you?
>>
>> Bob
>>
>> On 7 Feb 2011, at 23:25, Wayne Conrad wrote:
>>
>>> Is there anything I can do to achieve the illusion of atomic update of a
>>> set of attachments?  Here's the effect I'd like:
>>>
>>> For create:
>>> 1. Create a document.
>>> 2. Add attachments to it.
>>> 3. Only now does the document and all of its attachments become visible.
>>>
>>> For update:
>>> 1. Delete all of the document's attachments.
>>> 2. Add a new set of attachments to the document.
>>> 3. Only now does the new set of attachments appear to replace the old.
>>>
>>> I'm using Couchdb 1.0.2 and CouchRest 1.0.1.  I'm not opposed to cheating
>>> to achieve my goal.  Suggestions of "Did you think of doing this-other-thing
>>> instead?" are also welcome.
>>
>
>

Mime
View raw message