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