You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@couchdb.apache.org by Tim Kuijsten <in...@netsend.nl> on 2012/04/24 21:39:47 UTC

replication with document transformation

I'm currently replicating with filters, this works great to share 
certain documents between multiple systems based on their attributes. 
The thing is, I'd like to map certain names to a locally used name.

Example: we have 2 systems that want to share some documents with each 
other, based on a certain value for the "company" attribute.

The owners of database 1 want to share all documents that have 
"company": "Webstore Chicago" with the owners of database 2. All fine 
with a filter, but the owners of database 2 like to refer to "Webstore 
Chicago" as "Webstore 501". Is there a way to somehow transform the 
document while it's being replicated by the filter so in 1 database it's 
represented as "Webstore Chicago" and in the other db this same doc has 
"Webstore 501"?

Maybe if I could replicate the results of a view instead of the direct 
docs or something..

Regards,

Tim

Re: replication with document transformation

Posted by Matthieu Rakotojaona <ma...@gmail.com>.
On Tue, Apr 24, 2012 at 9:39 PM, Tim Kuijsten <in...@netsend.nl> wrote:
> Is there a way to somehow transform the document while it's
> being replicated by the filter so in 1 database it's represented as
> "Webstore Chicago" and in the other db this same doc has "Webstore 501"?

You basically want 2 versions of the same doc, wich are just 2
different docs. All I see is that you use one doc and store all the
context-specific names in the doc. You would then have as many
'context-names' as databases; This is not very good if you have
multiple dynamic nodes, but can be sufficient for your needs.

In fact couchDB nodes aim to be replication nodes that you can target
as you want; If you are using different docs based on the site, you
are in fact on the way to using 2 different datasets that are somewhat
related; I don't think this is a case taken into account by couchDB.

-- 
Matthieu RAKOTOJAONA

Re: replication with document transformation

Posted by Dave Cottlehuber <da...@muse.net.nz>.
On 24 April 2012 21:39, Tim Kuijsten <in...@netsend.nl> wrote:
> I'm currently replicating with filters, this works great to share certain
> documents between multiple systems based on their attributes. The thing is,
> I'd like to map certain names to a locally used name.
>
> Example: we have 2 systems that want to share some documents with each
> other, based on a certain value for the "company" attribute.
>
> The owners of database 1 want to share all documents that have "company":
> "Webstore Chicago" with the owners of database 2. All fine with a filter,
> but the owners of database 2 like to refer to "Webstore Chicago" as
> "Webstore 501". Is there a way to somehow transform the document while it's
> being replicated by the filter so in 1 database it's represented as
> "Webstore Chicago" and in the other db this same doc has "Webstore 501"?
>
> Maybe if I could replicate the results of a view instead of the direct docs
> or something..
>
> Regards,
>
> Tim

Hi Tim,

sorry I thought I send this through yesterday. I can only think of hacks.

Store the core data in a master doc, and have two linked docs that
represent the additional (transformed) info for each site. These linked docs
are then filterable individually for each site, and you can query
include_docs at
each end on the core data to retrieve the master + only the
site-specific transform.
Either munge it back together maybe in a list or show, or do it client side.

Sound workable?

A+
Dave