hammock

package module
v0.0.0-...-8c57b05 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 14, 2015 License: ISC Imports: 7 Imported by: 0

README

Hammock

Relax even further and have Hammock manage your CouchDB design documents while you manage JavaScript files in source control.

Usage

Create the following directory structure:

root
`-- design_doc_name
    |-- views
    |   |-- view_name
    |   |   |-- map.js
    |   |   `-- reduce.js
    |   `-- another_view
    |       `-- map.js
    `-- [shows|lists|filters|updates|validate]
        |-- function_name1.js
        `-- function_name2.js

And call Sync:


	if db, err := hammock.Database(db_host, db_name, db_username, db_password); err == nil {

		if changes, err := hammock.Sync(db, "root"); err == nil {

			if len(changes) > 0 {

				fmt.Println(strings.Join(changes, "\n"))
			}
		} else {

			log.Fatalln(err)
		}
	} else {

		log.Fatalln(err)
	}

Sync reads the directory structure and compares it with the design document in the CouchDB database (if such a design document does not exist it is created). Any differences are corrected treating the data read from disk as the correct version. Sync does not merge differences, it will always treat the state read from disk as the correct one.

The only difference Sync does not try to correct (yet) is deleting design documents that exist in the database but not on the disk.

TODO

  • Add tests.
  • Support CoffeeScript files.
  • Add an option for freezing documents, so that Sync will not attempt to override the CouchDB content.
  • Consider deleting documents from CouchDB when they do not exist on disk.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Sync

func Sync(db *CouchDB, path string) (changes []string, err error)

Types

type CouchDB

type CouchDB struct {
	couchdb.CouchDB
}

func Database

func Database(host, database, username, password string) (*CouchDB, error)

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL