incubator-couchdb-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From faust 1111 <faust...@gmail.com>
Subject Re: About denormalization and keep consistent
Date Thu, 08 Apr 2010 17:53:48 GMT
What difference?
if do
Author
  after_save
     if name_changed?
        Content.by_author(self).each {|content|
           content.author_name = self.name;
           content.save(bulk=true)
       }

or i start backend process to track Author _changes.

This code not guarantee that all contents will updated.


2010/4/8 Andrew Melo <andrew.melo@gmail.com>:
> On Thu, Apr 8, 2010 at 12:29 PM, faust 1111 <faust451@gmail.com> wrote:
>> I can catch changes in my app before save author, may be backend
>> process is surplus in my case.
>> i need consistent, when i update author name i must know that all
>> contents with author was updated success.
>
> Then their suggestion of watching _changes works for you. Start
> watching _changes. Make all your changes to the documents' authors.
> Any changes that come through on _changes, make sure they have the
> proper author. Keep watching _changes until you're sure that nobody
> has stale data they're waiting submit.
>
>
>>
>>
>> 2010/4/8 Zachary Zolton <zachary.zolton@gmail.com>:
>>> I suggest you check out the _changes API:
>>> http://books.couchdb.org/relax/reference/change-notifications
>>>
>>> Basically, if you have doc types A & B, where B maintains a denormed
>>> bit of A, then you can watch the _changes feed in a backend process.
>>> When an A gets updated, hit a view of all B's related to that
>>> particular A, and update the dernomed data.
>>>
>>> On Thu, Apr 8, 2010 at 10:20 AM, faust 1111 <faust451@gmail.com> wrote:
>>>> Hi guy's
>>>> I return back to my problem with denormalization.
>>>>
>>>> is it possible to keep consistent when apply denormalization?
>>>> For example
>>>> Content
>>>>   have author (we store author name and id in Content)
>>>>
>>>> When author name changed(that's happens not frequently)
>>>> i need find all content belong to this author and update author name
>>>> but what if this operation not finished (not all docs was updated)
>>>>
>>>> What i can do in this case?
>>>> Thanks.
>>>>
>>>
>>
>
>
>
> --
> --
> Andrew Melo
>

Mime
View raw message