Uploaded image for project: 'PHP Driver: Extension'
  1. PHP Driver: Extension
  2. PHPC-314

Implement type map syntax for documents within field paths

    • Type: Icon: New Feature New Feature
    • Resolution: Done
    • Priority: Icon: Major - P3 Major - P3
    • 1.5.0
    • Affects Version/s: 0.6.3
    • Component/s: None
    • None

      Implement an extension to the typemap system by allowing specific field paths which contain a BSON array or BSON document to be converted to an array, stdClass, or object of a specific type.

      This adds the "fieldPath" field to the TypeMap options as follows:

      [
        ‘root’ => (object|array|classname),
        ‘document’ => (object|array|classname),
        ‘array’ => (object|array|classname),
        // overrides defaults but not __pclass (“fieldPaths” name may change)
        ‘fieldPaths’ => [
          ‘Object’ => (object|array|classname),
          ‘Object.bob’ => …,
          ‘Object.jim.0’ => …,
          ‘Object.jim.1’ => …,
        ],
      ];
      

      Original description:

      While implementing PHPLIB-104, I realized the need for a type map to apply to nested fields within a command result (e.g. findAndModify returns a “value” document, and aggregate might return an array of documents in “results”).

      Possible syntax:

      setTypeMap([ 'databases.$' => 'DatabaseModelInfo' ])
      

            Assignee:
            derick Derick Rethans
            Reporter:
            jmikola@mongodb.com Jeremy Mikola
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: