In the shell, the autocomplete list for a db object does not include the watch helper.
It looks like the autocomplete function finds properties on an object using Object.keySet, defined here which iterates over enumerable properties.
Object.getOwnPropertyDescriptor shows that the watch property is not enumerable:
Object.getOwnPropertyDescriptor(db, "watch") { "value" : function (pipeline, options) { pipeline = pipeline || []; options = options || {}; assert(pipeline instanceof Array, "'pipeline' argument must be an array"); assert(options instanceof Object, "'options' argument must be an object"); let changeStreamStage = {fullDocument: options.fullDocument || "default"}; delete options.fullDocument; if (options.hasOwnProperty("resumeAfter")) { changeStreamStage.resumeAfter = options.resumeAfter; delete options.resumeAfter; } if (options.hasOwnProperty("startAtOperationTime")) { changeStreamStage.startAtOperationTime = options.startAtOperationTime; delete options.startAtOperationTime; } pipeline.unshift({$changeStream: changeStreamStage}); return this._runAggregate({aggregate: 1, pipeline: pipeline}, options); }, "writable" : true, "enumerable" : false, "configurable" : true }
But I'm not sure why watch is not enumerable while other similarly defined properties like getFreeMonitoringStatus are.
Additionally, db.watch does not show up in the output of db.help().
- is related to
-
SERVER-34001 Add db.watch() shell helper to open a change stream for a database
- Closed