Skip to content

Instantly share code, notes, and snippets.

@mirhec
Created January 17, 2015 06:47
Show Gist options
  • Save mirhec/d438d7b8d71a399fb069 to your computer and use it in GitHub Desktop.
Save mirhec/d438d7b8d71a399fb069 to your computer and use it in GitHub Desktop.
###
## This creates the db. If there occurs an error
## it will be printed out. If it succeeds, the
## callback next will be called.
###
createDb: (next) ->
r.dbCreate(config.rethinkdb.db).run @conn, (err, result) =>
if (err) and (not err.message.match(/Database `.*` already exists/))
console.log "Could not create the database `" + config.db + "`"
console.log err
process.exit 1
console.log "Database `" + config.rethinkdb.db + "` created."
if next?
next()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment