This commit is contained in:
Jonasz Bigda
2023-03-25 21:51:42 +01:00
parent 0db1d5117e
commit b332e9ceb0
1044 changed files with 37502 additions and 63938 deletions

View File

@@ -1,10 +1,15 @@
'use strict';
const Explain = require('../explain').Explain;
const MongoError = require('../core/error').MongoError;
const Aspect = {
READ_OPERATION: Symbol('READ_OPERATION'),
WRITE_OPERATION: Symbol('WRITE_OPERATION'),
RETRYABLE: Symbol('RETRYABLE'),
EXECUTE_WITH_SELECTION: Symbol('EXECUTE_WITH_SELECTION')
EXECUTE_WITH_SELECTION: Symbol('EXECUTE_WITH_SELECTION'),
NO_INHERIT_OPTIONS: Symbol('NO_INHERIT_OPTIONS'),
EXPLAINABLE: Symbol('EXPLAINABLE')
};
/**
@@ -16,6 +21,12 @@ const Aspect = {
class OperationBase {
constructor(options) {
this.options = Object.assign({}, options);
if (this.hasAspect(Aspect.EXPLAINABLE)) {
this.explain = Explain.fromOptions(options);
} else if (this.options.explain !== undefined) {
throw new MongoError(`explain is not supported on this command`);
}
}
hasAspect(aspect) {