Uploaded image for project: 'Swift Driver'
  1. Swift Driver
  2. SWIFT-976

Conform BSONObjectID to LosslessStringConvertible

    XMLWordPrintable

    Details

    • Type: New Feature
    • Status: Open
    • Priority: Major - P3
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: 2.0
    • Component/s: None
    • Labels:

      Description

      When trying to fetch the ID for an object from the parameters of a Request, there is a nice convenient method in Vapor that allows you to convert the string value from the route to any object that conforms to LosslessStringConvertible

       
      func exampleRoute(_ req: Request) {
          guard let id = req.parameters.get("id", as: BSONObjectID.self) else {
              return
          }
      }
      

      The only change required is replacing CustomStringConvertible with LosslessStringConvertible.

      public struct BSONObjectID: BSONValue, Equatable, LosslessStringCovertible, Codable {
       ....
      }
      

        Attachments

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            piers@fanschoir.com Piers Ebdon
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated: