Uploaded image for project: 'PHP Driver: Library'
  1. PHP Driver: Library
  2. PHPLIB-1185

Add Database::getCollection and Client::getDatabase

    • Type: Icon: Task Task
    • Resolution: Fixed
    • Priority: Icon: Unknown Unknown
    • 1.21.0
    • Affects Version/s: None
    • Component/s: CRUD
    • None
    • Needed
    • Hide

      1. What would you like to communicate to the user about this feature?
      We added three new methods:

      • MongoDB\Client::getCollection
      • MongoDB\Client::getDatabase
      • MongoDB\Database::getCollection

      These methods will eventually replace the existing selectCollection and selectDatabase methods. Due to their widespread use, we are not deprecating them at this time. However, we should update the documentation accordingly:

      • For the 1.x documentation, we need to add the new methods to the API docs. Their parameter list and behaviour is the same as the corresponding select method
      • For the 2.x documentation, we should replace all usages of selectCollection and selectDatabase with the corresponding get method. I would not suggest doing this for 1.x, as that could create confusion for users using an older version of the driver.
      Show
      1. What would you like to communicate to the user about this feature? We added three new methods: MongoDB\Client::getCollection MongoDB\Client::getDatabase MongoDB\Database::getCollection These methods will eventually replace the existing selectCollection and selectDatabase methods. Due to their widespread use, we are not deprecating them at this time. However, we should update the documentation accordingly: For the 1.x documentation, we need to add the new methods to the API docs. Their parameter list and behaviour is the same as the corresponding select method For the 2.x documentation, we should replace all usages of selectCollection and selectDatabase with the corresponding get method. I would not suggest doing this for 1.x, as that could create confusion for users using an older version of the driver.

      PHPLIB is the only driver that have named the method MongoDB\Database::selectCollection($name) 

      Proposition: 

      • Add MongoDB\Database::getCollection($name) as alias for MongoDB\Database::selectCollection($name)
      • Add MongoDB\Client::getDatabase($name) as alias for MongoDB\Client::selectDatabase($name)

      Deprecation notices will be added later in PHPLIB-1553, due to the widespread usage of the current methods. For example, the "Translate to language" feature in Compass uses these methods and will have to be adapted.

            Assignee:
            andreas.braun@mongodb.com Andreas Braun
            Reporter:
            jerome.tamarelle@mongodb.com Jérôme Tamarelle
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved: