batch/db.clear/db.clear.batch.js
function confirmClear() {
        var promptSchema = {
            properties: {
                confirm: {
                    description: 'Delete everything in the ' + config.env.toUpperCase() + ' database? (y or n) ',
                    pattern: /^[yn]$/,
                    message: 'Please respond with y or n. ',
                    required: true
                }
            }
        };

        // for safety reasons, we can't use this in production
        if (config.env === 'production') {
            return Q.reject('purging is NOT available for prod.');
        }

        // prompt the user to confirm they are deleting everything in the database
        var deferred = Q.defer();
        prompt.start();
        prompt.get(promptSchema, function (err, result) {
            if (err) {
                deferred.reject(err);
            }
            else if (result.confirm !== 'y') {
                log.info('purge cancelled');
                deferred.resolve(false);
            }
            // else user confirmed deletion so do it
            else {
                deferred.resolve(true);
            }
        });

        return deferred.promise;
    }
function confirmClear() {
        var promptSchema = {
            properties: {
                confirm: {
                    description: 'Delete everything in the ' + config.env.toUpperCase() + ' database? (y or n) ',
                    pattern: /^[yn]$/,
                    message: 'Please respond with y or n. ',
                    required: true
                }
            }
        };

        // for safety reasons, we can't use this in production
        if (config.env === 'production') {
            return Q.reject('purging is NOT available for prod.');
        }

        // prompt the user to confirm they are deleting everything in the database
        var deferred = Q.defer();
        prompt.start();
        prompt.get(promptSchema, function (err, result) {
            if (err) {
                deferred.reject(err);
            }
            else if (result.confirm !== 'y') {
                log.info('purge cancelled');
                deferred.resolve(false);
            }
            // else user confirmed deletion so do it
            else {
                deferred.resolve(true);
            }
        });

        return deferred.promise;
    }
function confirmClear ( ) { var promptSchema = { properties : { confirm : { description : 'Delete everything in the ' + config . env . toUpperCase ( ) + ' database? (y or n) ' , pattern : / ^[yn]$ / , message : 'Please respond with y or n. ' , required : true } } } ; // for safety reasons, we can't use this in production if ( config . env === 'production' ) { return Q . reject ( 'purging is NOT available for prod.' ) ; } // prompt the user to confirm they are deleting everything in the database var deferred = Q . defer ( ) ; prompt . start ( ) ; prompt . get ( promptSchema , function ( err , result ) { if ( err ) { deferred . reject ( err ) ; } else if ( result . confirm !== 'y' ) { log . info ( 'purge cancelled' ) ; deferred . resolve ( false ) ; } // else user confirmed deletion so do it else { deferred . resolve ( true ) ; } } ) ; return deferred . promise ; }
Confirm with the user that they definitately want to purge
@returns {*}
Confirm with the user that they definitately want to purge