Uploaded image for project: 'Node.js Driver'
  1. Node.js Driver
  2. NODE-5660

Use MongoDBNamespace consistently and remove string parsing for namespaces

    • Type: Icon: Task Task
    • Resolution: Unresolved
    • Priority: Icon: Minor - P4 Minor - P4
    • None
    • Affects Version/s: None
    • Component/s: CMAP
    • Labels:
    • Hide

      1. What would you like to communicate to the user about this feature?
      2. Would you like the user to see examples of the syntax and/or executable code and its output?
      3. Which versions of the driver/connector does this apply to?

      Show
      1. What would you like to communicate to the user about this feature? 2. Would you like the user to see examples of the syntax and/or executable code and its output? 3. Which versions of the driver/connector does this apply to?

      While monitoring a command, given collection name containing a '.' [the collectionName
       helper method|https://github.com/mongodb/node-mongodb-native/blob/35255976074fdb6c986e4bc224a83464d0030f0d/src/cmap/command_monitoring_events.ts#L186] the method will return the collection name until the first period.

      Ex: collectionName on a collection 'fs.chunk42' will return 'fs' 

      This is likely because of command monitoring failing to use the MongoDBNamespace class, and trying to separate database and collection names on its own.

      The helper is used in extractCommand(command: WriteProtocolMessageType), and it will fail to parse the collectionName for legacy find commands (op_query) so it is unused.

      Use Case

      As a... user of the Node Driver
      I want... organize our namespace handling
      So that... we don't have repeated potentially buggy string-splitting/parsing behavior

      Acceptance Criteria

      Implementation Requirements

      • Find all cases where a database and collection name are needed.
        • Replace them with MongoDBNamespace instances.
        • Update the ns helper to accept a db and collection name string as two arguments
        • Remove (or cease use of) fromString helper that parses strings into namespaces
      • Remove database name validation (preventing a dot in the name)

      Testing Requirements

      • Add a test that a database can be created with a dot in its name, and any subsequent operation will fail as a result.

      Documentation Requirements

      • None

            Assignee:
            Unassigned Unassigned
            Reporter:
            aditi.khare@mongodb.com Aditi Khare
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: