all files / lib/offshore/adapter/sync/strategies/ drop.js

81.82% Statements 9/11
50% Branches 2/4
100% Functions 3/3
90% Lines 9/10
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39                        12×     12×                       12× 12×   12× 12×        
/**
 * Module dependencies
 */
 
var _ = require('lodash');
var getRelations = require('../../../utils/getRelations');
 
 
/**
 * Drop and recreate collection
 *
 * @param  {Function} cb
 */
 
module.exports = function drop(cb) {
  var self = this;
 
  // Refuse to run this migration strategy in production.
  Iif (process.env.NODE_ENV === 'production') {
    return cb(new Error('`migrate: "drop"` strategy is not supported in production, please change to `migrate: "safe"`.'));
  }
 
  // Find any junctionTables that reference this collection
  // var relations = getRelations({
  //   schema: self.query.offshore.schema,
  //   parentCollection: self.collection
  // });
 
  // Pass along relations to the drop method
  // console.log('Dropping ' + self.collection);
  this.drop(function afterDrop(err, data) {
    Iif (err) return cb(err);
 
    self.define(function() {
      cb.apply(null, Array.prototype.slice.call(arguments));
    });
  });
};