Uploaded image for project: 'Core Server'
  1. Core Server
  2. SERVER-37062

db.watch does not show up in autocomplete or help

    • Type: Icon: Bug Bug
    • Resolution: Fixed
    • Priority: Icon: Minor - P4 Minor - P4
    • 4.2.0
    • Affects Version/s: 4.1.2
    • Component/s: Shell
    • Labels:
    • Query Optimization
    • Fully Compatible
    • ALL
    • v4.0
    • Query 2019-06-03
    • 0

      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().

            Assignee:
            backlog-query-optimization [DO NOT USE] Backlog - Query Optimization
            Reporter:
            kevin.albertson@mongodb.com Kevin Albertson
            Votes:
            0 Vote for this issue
            Watchers:
            9 Start watching this issue

              Created:
              Updated:
              Resolved: