examples/attachment-stream2.js
function initDB () {
  return db.listDatabases()
    .then(response => {
      if (response.data.indexOf(dbName) !== -1) {
        // database already exists
        return Promise.resolve('ok')
      } else {
        // create new database
        return db.createDatabase(dbName).then(() => 'ok')
      }
    })
}
function initDB () {
  return db.listDatabases()
    .then(response => {
      if (response.data.indexOf(dbName) !== -1) {
        // database already exists
        return Promise.resolve('ok')
      } else {
        // create new database
        return db.createDatabase(dbName).then(() => 'ok')
      }
    })
}
function initDB ( ) { return db . listDatabases ( ) . then ( response => { if ( response . data . indexOf ( dbName ) !== - 1 ) { // database already exists return Promise . resolve ( 'ok' ) } else { // create new database return db . createDatabase ( dbName ) . then ( ( ) => 'ok' ) } } ) }
create db if it does not already exist
@return {Promise}
create db if it does not already exist