MongoDB\BSON\Persistable::bsonSerializeProvides an array or document to serialize as BSON Description
abstract public arraystdClassMongoDB\BSON\Document MongoDB\BSON\Persistable::bsonSerialize()
Called during serialization of the object to BSON. The method must return an array, stdClass, or MongoDB\BSON\Document. The return value will always be serialized as a BSON document. The serialized document will include a field containing the class name of the object. For this reason, it is not possible to return a MongoDB\BSON\PackedArray instance in this method. Users are encouraged to include an _id property (e.g. a MongoDB\BSON\ObjectId initialized in the constructor) when returning data for a BSON root document. In the absence of an _id property, the extension or server will generate a MongoDB\BSON\ObjectId for insert or upsert operations, respectively. ParametersThis function has no parameters. Return ValuesAn array, stdClass, or MongoDB\BSON\Document to be serialized as a BSON document. Changelog
See Also
|