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

db.watch does not show up in autocomplete or help

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor - P4
    • Resolution: Fixed
    • 4.1.2
    • 4.2.0
    • Shell
    • Query Optimization
    • Fully Compatible
    • ALL
    • v4.0
    • Query 2019-06-03
    • 0

    Description

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

      Attachments

        Issue Links

          Activity

            People

              backlog-query-optimization Backlog - Query Optimization
              kevin.albertson@mongodb.com Kevin Albertson
              Votes:
              0 Vote for this issue
              Watchers:
              9 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: