find_one_and_delete.js 613 B

123456789101112131415161718192021
  1. 'use strict';
  2. const FindAndModifyOperation = require('./find_and_modify');
  3. class FindOneAndDeleteOperation extends FindAndModifyOperation {
  4. constructor(collection, filter, options) {
  5. // Final options
  6. const finalOptions = Object.assign({}, options);
  7. finalOptions.fields = options.projection;
  8. finalOptions.remove = true;
  9. // Basic validation
  10. if (filter == null || typeof filter !== 'object') {
  11. throw new TypeError('Filter parameter must be an object');
  12. }
  13. super(collection, filter, finalOptions.sort, null, finalOptions);
  14. }
  15. }
  16. module.exports = FindOneAndDeleteOperation;