-
Type: New Feature
-
Resolution: Done
-
Priority: Major - P3
-
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' ])
- is depended on by
-
PHPC-922 Improve specificity in generic corrupt BSON exception message
- Closed
-
PHPC-1154 Implement wild card syntax for typemap field paths
- Closed
-
PHPC-1155 Implement field paths for scalar types
- Closed
-
PHPLIB-242 Refactor command operations to use field path syntax for type maps
- Closed
- is related to
-
PHPC-319 Top level documents should be deserialized as stdClass by default
- Closed
-
PHPC-315 Support explicit type mapping for top-level documents
- Closed
- related to
-
PHPLIB-74 Default BSON document and array unserialization to ArrayObject classes
- Closed
-
PHPC-329 ODM class should always supersede the type map
- Closed
-
PHPC-640 Implement interfaces for userland BSON type classes
- Closed
-
PHPC-2039 Remove disabled debugging code in bson.c
- Closed
-
PHPLIB-138 Add global typemap configuration
- Closed
- links to