Several developers support the synchronization of CouchDB with aphorism

I am considering using CouchDB for the upcoming web development project.

What is the best way to keep the repo in a CouchDB document in sync between the various developers who all run the application locally?

Example. Suppose developer A creates a new document with a view or design in Couch, or simply adds a field to an existing view. They also check some client-side code that expects this field to be displayed on the CouchDB screen. Developer B enters the system and updates to the latest source code, pulling changes to the client side of the developer. How does developer B get the Couch changes that accompany client code?

In a typical DBMS, this would be achieved by checking the set of SQL files or migrating data to the SCM system. After Developer B updates his code, he will run new SQL or migration scripts to update his database schema.

Perhaps Couch has a way to export / import project documents and view definitions and validate them in the SCM system? Maybe I just need my RDBMS background brainwashing to be deprogrammed.

+4
source share
3 answers

I usually stored .js files of my view map and downsized functions and saved them in my code repository. A common template is to have a folder for each view and a separate .js file for each view function (map / reduce). Example:

views/ tags/ map.js reduce.js users/ map.js reduce.js 

The contents of views/tags/map.js is just a JavaScript display function, for example:

 function(doc) { if(doc.tags && doc.tags.length) { for(var index in doc.tags) { emit(doc.tags[index], null); } } } 

You can then control your views in any way using CouchApp or something like this to synchronize everything with the CouchDB instance. Of course, I don’t know what the “best practice” is, but this is what I did and works well with my team.

+4
source

Low tech solution:

The export-import file format looks like JSON, which makes it not like moving SQL files.

+1
source

Recommended Ryan offers are good. DB :: CouchDB :: Schema is a perl library with a script package that can export and import your project documents. This can help automate the work for you.

0
source

All Articles