Skip to content

Instantly share code, notes, and snippets.

@kemitchell
Created February 2, 2014 07:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kemitchell/8764263 to your computer and use it in GitHub Desktop.
Save kemitchell/8764263 to your computer and use it in GitHub Desktop.
Node + CouchDB + Design Documents + NPM postinstall
# TODO: Connect to CouchDB using process.env properties
module.exports = {}
module.exports = [
{
_id: '_design/objects'
views:
by_type:
map: (doc) -> emit doc.type, null
}
]
#!/bin/sh
heroku labs:enable user-env-compile
db = require './database'
update = (obj, callback) ->
db.get obj._id, (error, existing) ->
obj._rev = existing._rev if !error
db.insert obj, callback
async = require 'async'
designs = require './designs'
module.exports = (done) ->
functions = designs.map (doc) ->
(callback) ->
console.log "Storing design #{d._id}"
update doc, callback
async.parallel functions, done
unless module.parent
module.exports -> console.log "Done"
{
"scripts": {
"postinstall": "coffee install_design_docs.coffee"
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment