Uploaded image for project: 'Rust Driver'
  1. Rust Driver
  2. RUST-1856

[Feature Request] Allow access to Client from Database

    • Type: Icon: Improvement Improvement
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 3.0.0
    • Affects Version/s: None
    • Component/s: None
    • None
    • Rust Drivers

      The underlying reason for this request has to do with transactions. I have an application where we create the Database handle at startup and then pass that around to the places that need it. This works well for us, as it's a single value which is fully configured for our purpose. The exception is the couple locations where we want to use transactions.

      There doesn't appear to be a way to initiate a transaction using only a Database handle; we need a Client. I'm hoping to find a solution that doesn't require we refactor our whole codebase to support passing two separate values.

      Database already has a reference to Client. It seems like it would be fine to offer an accessor method:

       

      ```

      /// Get the Client used by this Database

      pub fn client(&self) -> Client

      {     self.inner.client.clone() }

      ```

            Assignee:
            abraham.egnor@mongodb.com Abraham Egnor
            Reporter:
            grijalva@gmail.com Dave Grijalva
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: