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

Add a NestedKey helper type that enumerates the union of possible nested keys

    • Not Needed

      Use Case

      As a typescript user I want to create dot notation keys from string interpolation that can be verified against a type that checks the total string as a valid nested specifier.

      This would help work around the issue reported in NODE-4933.

      User example

      Unable to find source-code formatter for language: typescript. Available languages are: actionscript, ada, applescript, bash, c, c#, c++, cpp, css, erlang, go, groovy, haskell, html, java, javascript, js, json, lua, none, nyan, objc, perl, php, python, r, rainbow, ruby, scala, sh, sql, swift, visualbasic, xml, yaml
      type Pet = { name: string; attributes: { bestFriends: Array<{ _id: Date; name: string }> } }
      let newName = 'spot'
      for (let i = 0; i < friends.length; i++) {
        const nestedKey: NestedKey<TSchema> = `attributes.bestFriends.${i}.name`
        // NestedKey here provides an assertion that the calculated key is correct
        const $set: Document = { [nestedKey]: newName }
        await pets.updateOne({}, { $set })
      }
      

      Dependencies

      • upstream and/or downstream requirements and timelines to bear in mind

      Unknowns

      • questions that need to be answered to determine implementation

      Acceptance Criteria

      Implementation Requirements

      • functional reqs, potential snafus to avoid, performance targets, etc

      Testing Requirements

      • unit test, spec test sync, etc

      Documentation Requirements

      • DOCSP ticket, API docs, etc

      Follow Up Requirements

      • additional tickets to file, required releases, etc

            Assignee:
            Unassigned Unassigned
            Reporter:
            neal.beeken@mongodb.com Neal Beeken
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: