Skip to content

Commit

Permalink
Don’t print error if the DB already exists
Browse files Browse the repository at this point in the history
Detect return code 412 as "DB already exists"
* http://docs.couchdb.org/en/1.6.1/api/database/common.html#put--db
  • Loading branch information
srl295 committed May 19, 2016
1 parent 22921bc commit 31370cf
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,8 @@ function initDBConnection() {

//check if DB exists if not create
cloudant.db.create(dbCredentials.dbName, function (err, res) {
if (err) { console.log('could not create db ', err); }
if (err && err.statusCode === 412) { return console.log('OK: db already existed', dbCredentials.dbName); }
if (err) { return console.log('could not create db ', err); }
});
db = cloudant.use(dbCredentials.dbName);
}
Expand Down

0 comments on commit 31370cf

Please sign in to comment.