pp

Mirrors nested JSON documents (e.g. from CouchDB) to the filesystem where one can work on it.

npm install pp
2 downloads in the last day
14 downloads in the last week
27 downloads in the last month

A little clone/push story for nested couchdb documents

told by wactbprot.


        +---------+                 +---------+
        | CouchDB |                 | CouchDB |
        |---------|                 |---------|
        |         |                 |         |
        | db      |                 | test    |
        |         |                 |         |
        +-+-------+                 +---------+
          |                             ^
          |                             |
pp clone couchdoc_i             pp push couchdoc_i use test
          |        +-------------+      |
          +------->| filesystem  +------+
                   |-------------|
                   |             |
                   | couchdoc_i  |       +-----------------+
                   | couchdoc_ii |       | *  edit         |
                   |    ...      |       | documents in    |
                   +-------------+       | youre favorite  |
                          ^              | emacs mode      |
                          |              | * use           |
                          |              |  - git          |
                          |              |  - grep         |
                          +------------->|  - cat          |
                                         |  - sed          |
                                         |  - ...          |
                                         +-----------------+

NPM

requirements

  • nano
  • underscore
  • a file named .couchapprc as provided by erica or couchapp in the folder where pp is executed:

      // .couchappcr
      {
      "env": {
        "test": {
          "db": "http://localhost:5984/test"
           }
        "default": {
          "db": "http://localhost:5984/db"
        }
       }
      }
    

install

npm install pp

usage

   pp clone    doc-id  [level 2] [folder ./docs] [use default]
   pp push     doc-id  [folder ./docs] [use default]);        
   pp rm       doc-id  [folder ./docs] [use default]);        
   pp revfresh doc-id  [folder ./docs] [use default]);        

revfresh

revfresh refreshs the rev. If you receive a conflict error message and you know whats going on you can say

  pp revfresh  doc-id [use default] [folder ./docs]

The ./doc-id/_rev.str.txt will be overwritten with the revision from the database so that a following push makes no trouble.

level

The level param controls how deep the folder structer becomes on cloning a document.

rm

To remove a complete document on the filesystem one can use:

  pp rm doc-id [use default] [folder ./docs]

It does the same as a rm -r folder/doc-id but with nodejs and therefore cooler no smiley here

emacs tip

It may occur that the default behavior of emacs: add a newline to the last line without asking is annoying. One can follow the emacs manual subsection 18.3.3 (Customizing Saving of Files) and write:

 (setq require-final-newline nil)
 (setq mode-require-final-newline nil)

in the .emacs

npm loves you