(parent?: OperationParent, options?: CommandOperationOptions)
| 84 | explain?: Explain; |
| 85 | |
| 86 | constructor(parent?: OperationParent, options?: CommandOperationOptions) { |
| 87 | super(options); |
| 88 | this.options = options ?? {}; |
| 89 | |
| 90 | // NOTE: this was explicitly added for the add/remove user operations, it's likely |
| 91 | // something we'd want to reconsider. Perhaps those commands can use `Admin` |
| 92 | // as a parent? |
| 93 | const dbNameOverride = options?.dbName || options?.authdb; |
| 94 | if (dbNameOverride) { |
| 95 | this.ns = new MongoDBNamespace(dbNameOverride, '$cmd'); |
| 96 | } else { |
| 97 | this.ns = parent |
| 98 | ? parent.s.namespace.withCollection('$cmd') |
| 99 | : new MongoDBNamespace('admin', '$cmd'); |
| 100 | } |
| 101 | |
| 102 | this.readConcern = ReadConcern.fromOptions(options); |
| 103 | this.writeConcern = WriteConcern.fromOptions(options); |
| 104 | |
| 105 | if (this.hasAspect(Aspect.EXPLAINABLE)) { |
| 106 | this.explain = Explain.fromOptions(options); |
| 107 | if (this.explain) validateExplainTimeoutOptions(this.options, this.explain); |
| 108 | } else if (options?.explain != null) { |
| 109 | throw new MongoInvalidArgumentError(`Option "explain" is not supported on this command`); |
| 110 | } |
| 111 | } |
| 112 | |
| 113 | override get canRetryWrite(): boolean { |
| 114 | if (this.hasAspect(Aspect.EXPLAINABLE)) { |
nothing calls this directly
no test coverage detected