old_contents: 'use strict';
  
  const boom = require('boom');
  const hu = require('../lib/handler-utils');
  
  module.exports = (route, options) => {
    const Model = options.model;
  
    return (req, reply) => {
  
      const query = hu.getIdQuery(options, req);
      if (options.preQuery) options.preSend(query); // query extension point
      Model.remove(query, (err, mod) => {
  
        if (err) return reply(boom.badImplementation(err));
        return reply(mod);
      });
    };
  };
  
  module.exports.validOptions = {
    idKey: hu.schemas.idKey,
  };
  
new_contents: 'use strict';
  
  const boom = require('boom');
  const hu = require('../lib/handler-utils');
  
  module.exports = (route, options) => {
    const Model = options.model;
  
    return (req, reply) => {
  
      const query = hu.getIdQuery(options, req);
      if (options.preQuery) options.preSend(query); // query extension point
      Model.findOneAndRemove(query, (err, mod) => {
  
        if (err) return reply(boom.badImplementation(err));
        return reply(mod);
      });
    };
  };
  
  module.exports.validOptions = {
    idKey: hu.schemas.idKey,
  };
  
subject: return document instead of mongo result