functions/tip-service.js
/**
 * Adds all tips from the file to Firestore.
 * @return {Promise}
 */
Adds all tips from the file to Firestore.
@return {Promise}
Adds all tips from the file to Firestore . @return { Promise }
function addTips() {
  const tips = require('./tipsDB.json');
  let batch = db.batch();
  let tipsRef = db.collection(FirestoreNames.TIPS);
  tips.forEach(function(tip) {
    let tipRef = tipsRef.doc();
    batch.set(tipRef, tip);
  });
  return batch.commit()
    .then(function() {
      console.log(`Tips DB succesfully restored`);
    })
    .catch(function(error) {
      throw new Error(`Error restoring tips DB: ${error}`);
    });
}
function addTips ( ) { const tips = require ( './tipsDB.json' ) ; let batch = db . batch ( ) ; let tipsRef = db . collection ( FirestoreNames . TIPS ) ; tips . forEach ( function ( tip ) { let tipRef = tipsRef . doc ( ) ; batch . set ( tipRef , tip ) ; } ) ; return batch . commit ( ) . then ( function ( ) { console . log ( ` ` ) ; } ) . catch ( function ( error ) { throw new Error ( ` ${ error } ` ) ; } ) ; }
Adds all tips from the file to Firestore.
Adds all tips from the file to Firestore .