Created
February 2, 2014 07:27
-
-
Save kemitchell/8764263 to your computer and use it in GitHub Desktop.
Node + CouchDB + Design Documents + NPM postinstall
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# TODO: Connect to CouchDB using process.env properties | |
module.exports = {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module.exports = [ | |
{ | |
_id: '_design/objects' | |
views: | |
by_type: | |
map: (doc) -> emit doc.type, null | |
} | |
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
heroku labs:enable user-env-compile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"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