Created
August 26, 2011 22:44
-
-
Save mahemoff/1174609 to your computer and use it in GitHub Desktop.
Cradle (CouchDB+Node) routine to prepare a new DB, destroying the old one if it already exists. Good for prepping a data dump.
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
data = | |
init: () -> | |
data.emptyDB "animals", () -> | |
console.log "ready" | |
# now populate your new DB | |
emptyDB: (name, done) -> | |
db = new(cradle.Connection)().database(name); | |
db.exists (err, exists) -> | |
if exists | |
db.destroy () -> | |
console.log "destroyed the old one" | |
db.create() | |
done | |
else | |
console.log "no old one found" | |
db.create() | |
done | |
data.init() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment