app/util/cloudantDb.js
/**
   * Inserts (or updates, if exists) the doc into the DB
   * @returns {promise} - A promise representing the query to the DB
   */
Inserts (or updates, if exists) the doc into the DB
@returns {promise} - A promise representing the query to the DB
Inserts ( or updates if exists ) the doc into the DB @returns { promise } - A promise representing the query to the DB
insertOrUpdate(doc) {
    return new Promise((resolve, reject) => {
      db.insert(doc, function(err, body, header) {
        if (err) {
          console.log('insertion failed: ' + err.message);
          reject(err);
        } else {
          resolve(body, header);
        }
      });
    });
  }
insertOrUpdate ( doc ) { return new Promise ( ( resolve , reject ) => { db . insert ( doc , function ( err , body , header ) { if ( err ) { console . log ( 'insertion failed: ' + err . message ) ; reject ( err ) ; } else { resolve ( body , header ) ; } } ) ; } ) ; }
Inserts (or updates, if exists) the doc into the DB
 @returns {promise} - A promise representing the query to the DB
Inserts ( or updates if exists ) the doc into the DB @returns { promise } - A promise representing the query to the DB