Skip to content
/ hammock Public

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

License

Notifications You must be signed in to change notification settings

leeor/hammock

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

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

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages