-
Notifications
You must be signed in to change notification settings - Fork 34
DOCSP-47059: Work with BSON #263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
✅ Deploy Preview for docs-php-library ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
selected classes (e.g. :phpmethod:`MongoDB\Client::getDatabase()`). | ||
**BSON**, or Binary JSON, is the data format that MongoDB uses to organize | ||
and store data. This data format includes all JSON data structure types and | ||
supports additional types, including dates, different-sized integers, ``ObjectId`` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
S: to resolve vale error
supports additional types, including dates, different-sized integers, ``ObjectId`` | |
also supports other types, such as dates, different-sized integers, ``ObjectId`` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good work, There are a few areas that I wanted to see some more context + some style guide fixes
values, and binary data. The {+library-short+} provides the ``MongoDB\Model\BSONArray`` | ||
and ``MongoDB\Model\BSONDocument`` types to store BSON data. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
S: Use API links
For a complete list of supported BSON types, see :manual:`BSON Types | ||
</reference/bson-types>` in the {+mdb-server+} manual. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For a complete list of supported BSON types, see :manual:`BSON Types | |
</reference/bson-types>` in the {+mdb-server+} manual. | |
To view a complete list of supported BSON types, see :manual:`BSON Types | |
</reference/bson-types>` in the {+mdb-server+} manual. |
|
||
Persistable Classes | ||
------------------- | ||
You can create a BSON document by using the same notation you use to create an |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
S: style guide
You can create a BSON document by using the same notation you use to create an | |
You can create a BSON document by using the same notation that you use to create an |
You can modify the contents of a BSON document by using the same notation you use to | ||
modify an associative array in {+language+}. This example makes the following changes | ||
to the :ref:`sample BSON document <php-bson-sample>`: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can modify the contents of a BSON document by using the same notation you use to | |
modify an associative array in {+language+}. This example makes the following changes | |
to the :ref:`sample BSON document <php-bson-sample>`: | |
You can modify the contents of a BSON document by using the same notation that you use to | |
modify an associative array in {+language+}. This example makes the following changes | |
to the :ref:`sample BSON document <php-bson-sample>`: |
}, | ||
"coord" : [-73.982419, 41.579505] | ||
"cuisine" : "Pizza", | ||
"name" : "Mongo's Pizza" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
S: consider using a name that doesn't include a char that needs escaping, unless you specifically want to demonstrate this (which is good too!)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated, I don't think it's necessary to demonstrate
Example | ||
``````` | ||
|
||
Consider the following ``Person`` class definition: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
S: explain what is special/expected by defining the class this way
you must specify serialization logic by defining the ``bsonSerialize()`` | ||
and ``bsonUnserialize()`` methods. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you must specify serialization logic by defining the ``bsonSerialize()`` | |
and ``bsonUnserialize()`` methods. | |
you must specify serialization logic by defining the ``bsonSerialize()`` | |
and ``bsonUnserialize()`` methods in your class definition. |
.. literalinclude:: /includes/bson.php | ||
:language: php | ||
:dedent: | ||
:start-after: start-backed-enum | ||
:end-before: end-backed-enum |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
S: consider adding highlighting for the methods of interest
Enums cannot implement the ``MongoDB\BSON\Unserializable`` and | ||
``MongoDB\BSON\Persistable`` interfaces, since enum cases have no | ||
state and cannot be instantiated like class objects. However, pure and backed | ||
enums can implement ``MongoDB\BSON\Serializable``, which you can use to | ||
override the default enum serialization behavior. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Enums cannot implement the ``MongoDB\BSON\Unserializable`` and | |
``MongoDB\BSON\Persistable`` interfaces, since enum cases have no | |
state and cannot be instantiated like class objects. However, pure and backed | |
enums can implement ``MongoDB\BSON\Serializable``, which you can use to | |
override the default enum serialization behavior. | |
Enums cannot implement the ``MongoDB\BSON\Unserializable`` and | |
``MongoDB\BSON\Persistable`` interfaces because enum cases have no | |
state and cannot be instantiated like class objects. However, pure and backed | |
enums can implement ``MongoDB\BSON\Serializable``, which you can use to | |
override the default enum serialization behavior. |
:dedent: | ||
:start-after: start-backed-enum | ||
:end-before: end-backed-enum | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
S: consider demonstrating an example as you did in the previous section of the serialization roundtrip
.. note:: | ||
|
||
The preceding code changes only the in-memory values of the sample BSON | ||
document. It does not run any database operations that change values stored | ||
in MongoDB. To learn how to modify documents stored in MongoDB, see the | ||
:ref:`php-write-update` guide. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks good and addresses my concern!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
looks great! thanks for implementing all the feedback
The following sections describe how to configure your application's | ||
serialization of BSON data: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
S: simplify
The following sections describe how to configure your application's | |
serialization of BSON data: | |
The following sections describe how to configure the way your application | |
serializes BSON data: |
:start-after: start-enum-serialize | ||
:end-before: end-enum-serialize | ||
:language: php | ||
:dedent: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
S: maybe its worth adding a sentence below here that says that the USER enum value was stored as a 1 in MongoDB, but deserialized correctly into the enum value. But can also leave out if its obvious/redundant.
* Add redirects workflow * DOCSP-47058: Shift TOC (#251) * DOCSP-47058: Shift TOC * edits * issues and help, edits * fix errors * redirects * landing * RR feedback * RR feedback 2 * fix gh action * DOCSP-47057: Network compression (#254) * DOCSP-47057: Network compression * delete * edits * MM feedback * DOCSP-47055: Collation (#258) * DOCSP-47055: Collation * add to each page * edit * edits * list format * SA feedback * DOCSP-47060: Causal consistency (#261) * DOCSP-47060: Causal consistency * edits * Fix phpcs workflow * First fixes * Fix trailing commas * Fix string quoting * Fix whitespace errors * Fix use statements * Exclude sniff that would break comments * Fix multiline function declarations * Fix wrong array indentation * Fix snake_case variable names * Remove more false-positive errors * Fix control structure spacing * Fix arrays * Use property promotion * Simplify multiline array rules * Check code formatting (#265) * Check code formatting * fix highlighting * DOCSP-47059: Work with BSON (#263) * DOCSP-47059: Work with BSON * edits * RR feedback * enum ex * feedback * DOCSP-50222: Reorganize auth pages (#266) * DOCSP-50222: Reorganize auth pages * edits * fix * snooty * DOCSP-47065: Load balancing (#257) * DOCSP-47065: Load balancing * edit * word * RR feedback * DOCSP-47056: Monitoring (#260) * DOCSP-47056: Monitoring * fixes * fix * wording * table * widths * SA feedback * PV feedback * DOCSP-47071: Extended JSON (#268) * DOCSP-47071: Extended JSON * edits * vale * feedback * DOCSP-47072: Client parameters (#273) * DOCSP-47072: Client parameters * edits * fix * DOCSP-47069: Polling SRV records (#274) * DOCSP-50753: agg tutorial link (#275) * DOCSP-47063: Logging (#267) * DOCSP-47063: Logging * edits * word * feedback * code edit * fix * JT feedback * edit * spacing * gh link * JT feedback 2 * RR feedback * DOCSP-50185: Connection troubleshooting (#272) * DOCSP-50185: Connection troubleshooting * edits * remove sharedinclude * fix * wording * fix * MM feedback * DOCSP-50220: Break up FAQ (#276) * DOCSP-50220: Break up FAQ * edits * RM feedback * AB feedback * fix highlight * DOCSP-50960: Install with pie (#278) * DOCSP-50960: Install with pie * edits * RR feedback * JT feedback * DOCSP-51123: CC edits and cleanup (#279) * DOCSP-51123: CC edits and cleanup * build * composer * code errors * commas * more phpcs errors * edits * phpcs * code fixes * more phpcs * fix * RR feedback * DOCSP-50772: isView() (#281) * DOCSP-50772: isView() * fix manual link Co-authored-by: Nora Reidy <[email protected]> --------- Co-authored-by: Nora Reidy <[email protected]> * phpcs * vale * use toc labels/titles * more titles * label * Drop psalm analysis for doc examples * AB feedback * filter * title changes * build errors --------- Co-authored-by: Andreas Braun <[email protected]> Co-authored-by: Rea Rustagi <[email protected]>
* Add redirects workflow * DOCSP-47058: Shift TOC (#251) * DOCSP-47058: Shift TOC * edits * issues and help, edits * fix errors * redirects * landing * RR feedback * RR feedback 2 * fix gh action * DOCSP-47057: Network compression (#254) * DOCSP-47057: Network compression * delete * edits * MM feedback * DOCSP-47055: Collation (#258) * DOCSP-47055: Collation * add to each page * edit * edits * list format * SA feedback * DOCSP-47060: Causal consistency (#261) * DOCSP-47060: Causal consistency * edits * Fix phpcs workflow * First fixes * Fix trailing commas * Fix string quoting * Fix whitespace errors * Fix use statements * Exclude sniff that would break comments * Fix multiline function declarations * Fix wrong array indentation * Fix snake_case variable names * Remove more false-positive errors * Fix control structure spacing * Fix arrays * Use property promotion * Simplify multiline array rules * Check code formatting (#265) * Check code formatting * fix highlighting * DOCSP-47059: Work with BSON (#263) * DOCSP-47059: Work with BSON * edits * RR feedback * enum ex * feedback * DOCSP-50222: Reorganize auth pages (#266) * DOCSP-50222: Reorganize auth pages * edits * fix * snooty * DOCSP-47065: Load balancing (#257) * DOCSP-47065: Load balancing * edit * word * RR feedback * DOCSP-47056: Monitoring (#260) * DOCSP-47056: Monitoring * fixes * fix * wording * table * widths * SA feedback * PV feedback * DOCSP-47071: Extended JSON (#268) * DOCSP-47071: Extended JSON * edits * vale * feedback * DOCSP-47072: Client parameters (#273) * DOCSP-47072: Client parameters * edits * fix * DOCSP-47069: Polling SRV records (#274) * DOCSP-50753: agg tutorial link (#275) * DOCSP-47063: Logging (#267) * DOCSP-47063: Logging * edits * word * feedback * code edit * fix * JT feedback * edit * spacing * gh link * JT feedback 2 * RR feedback * DOCSP-50185: Connection troubleshooting (#272) * DOCSP-50185: Connection troubleshooting * edits * remove sharedinclude * fix * wording * fix * MM feedback * DOCSP-50220: Break up FAQ (#276) * DOCSP-50220: Break up FAQ * edits * RM feedback * AB feedback * fix highlight * DOCSP-50960: Install with pie (#278) * DOCSP-50960: Install with pie * edits * RR feedback * JT feedback * DOCSP-51123: CC edits and cleanup (#279) * DOCSP-51123: CC edits and cleanup * build * composer * code errors * commas * more phpcs errors * edits * phpcs * code fixes * more phpcs * fix * RR feedback * DOCSP-50772: isView() (#281) * DOCSP-50772: isView() * fix manual link Co-authored-by: Nora Reidy <[email protected]> --------- Co-authored-by: Nora Reidy <[email protected]> * phpcs * vale * use toc labels/titles * more titles * label * Drop psalm analysis for doc examples * AB feedback * filter * title changes * build errors --------- Co-authored-by: Andreas Braun <[email protected]> Co-authored-by: Rea Rustagi <[email protected]> (cherry picked from commit 70a7512)
* Add redirects workflow * DOCSP-47058: Shift TOC (mongodb#251) * DOCSP-47058: Shift TOC * edits * issues and help, edits * fix errors * redirects * landing * RR feedback * RR feedback 2 * fix gh action * DOCSP-47057: Network compression (mongodb#254) * DOCSP-47057: Network compression * delete * edits * MM feedback * DOCSP-47055: Collation (mongodb#258) * DOCSP-47055: Collation * add to each page * edit * edits * list format * SA feedback * DOCSP-47060: Causal consistency (mongodb#261) * DOCSP-47060: Causal consistency * edits * Fix phpcs workflow * First fixes * Fix trailing commas * Fix string quoting * Fix whitespace errors * Fix use statements * Exclude sniff that would break comments * Fix multiline function declarations * Fix wrong array indentation * Fix snake_case variable names * Remove more false-positive errors * Fix control structure spacing * Fix arrays * Use property promotion * Simplify multiline array rules * Check code formatting (mongodb#265) * Check code formatting * fix highlighting * DOCSP-47059: Work with BSON (mongodb#263) * DOCSP-47059: Work with BSON * edits * RR feedback * enum ex * feedback * DOCSP-50222: Reorganize auth pages (mongodb#266) * DOCSP-50222: Reorganize auth pages * edits * fix * snooty * DOCSP-47065: Load balancing (mongodb#257) * DOCSP-47065: Load balancing * edit * word * RR feedback * DOCSP-47056: Monitoring (mongodb#260) * DOCSP-47056: Monitoring * fixes * fix * wording * table * widths * SA feedback * PV feedback * DOCSP-47071: Extended JSON (mongodb#268) * DOCSP-47071: Extended JSON * edits * vale * feedback * DOCSP-47072: Client parameters (mongodb#273) * DOCSP-47072: Client parameters * edits * fix * DOCSP-47069: Polling SRV records (mongodb#274) * DOCSP-50753: agg tutorial link (mongodb#275) * DOCSP-47063: Logging (mongodb#267) * DOCSP-47063: Logging * edits * word * feedback * code edit * fix * JT feedback * edit * spacing * gh link * JT feedback 2 * RR feedback * DOCSP-50185: Connection troubleshooting (mongodb#272) * DOCSP-50185: Connection troubleshooting * edits * remove sharedinclude * fix * wording * fix * MM feedback * DOCSP-50220: Break up FAQ (mongodb#276) * DOCSP-50220: Break up FAQ * edits * RM feedback * AB feedback * fix highlight * DOCSP-50960: Install with pie (mongodb#278) * DOCSP-50960: Install with pie * edits * RR feedback * JT feedback * DOCSP-51123: CC edits and cleanup (mongodb#279) * DOCSP-51123: CC edits and cleanup * build * composer * code errors * commas * more phpcs errors * edits * phpcs * code fixes * more phpcs * fix * RR feedback * DOCSP-50772: isView() (mongodb#281) * DOCSP-50772: isView() * fix manual link Co-authored-by: Nora Reidy <[email protected]> --------- Co-authored-by: Nora Reidy <[email protected]> * phpcs * vale * use toc labels/titles * more titles * label * Drop psalm analysis for doc examples * AB feedback * filter * title changes * build errors --------- Co-authored-by: Andreas Braun <[email protected]> Co-authored-by: Rea Rustagi <[email protected]> (cherry picked from commit 70a7512) (cherry picked from commit f11a732)
* PHP Comprehensive Coverage (#282) * Add redirects workflow * DOCSP-47058: Shift TOC (#251) * DOCSP-47058: Shift TOC * edits * issues and help, edits * fix errors * redirects * landing * RR feedback * RR feedback 2 * fix gh action * DOCSP-47057: Network compression (#254) * DOCSP-47057: Network compression * delete * edits * MM feedback * DOCSP-47055: Collation (#258) * DOCSP-47055: Collation * add to each page * edit * edits * list format * SA feedback * DOCSP-47060: Causal consistency (#261) * DOCSP-47060: Causal consistency * edits * Fix phpcs workflow * First fixes * Fix trailing commas * Fix string quoting * Fix whitespace errors * Fix use statements * Exclude sniff that would break comments * Fix multiline function declarations * Fix wrong array indentation * Fix snake_case variable names * Remove more false-positive errors * Fix control structure spacing * Fix arrays * Use property promotion * Simplify multiline array rules * Check code formatting (#265) * Check code formatting * fix highlighting * DOCSP-47059: Work with BSON (#263) * DOCSP-47059: Work with BSON * edits * RR feedback * enum ex * feedback * DOCSP-50222: Reorganize auth pages (#266) * DOCSP-50222: Reorganize auth pages * edits * fix * snooty * DOCSP-47065: Load balancing (#257) * DOCSP-47065: Load balancing * edit * word * RR feedback * DOCSP-47056: Monitoring (#260) * DOCSP-47056: Monitoring * fixes * fix * wording * table * widths * SA feedback * PV feedback * DOCSP-47071: Extended JSON (#268) * DOCSP-47071: Extended JSON * edits * vale * feedback * DOCSP-47072: Client parameters (#273) * DOCSP-47072: Client parameters * edits * fix * DOCSP-47069: Polling SRV records (#274) * DOCSP-50753: agg tutorial link (#275) * DOCSP-47063: Logging (#267) * DOCSP-47063: Logging * edits * word * feedback * code edit * fix * JT feedback * edit * spacing * gh link * JT feedback 2 * RR feedback * DOCSP-50185: Connection troubleshooting (#272) * DOCSP-50185: Connection troubleshooting * edits * remove sharedinclude * fix * wording * fix * MM feedback * DOCSP-50220: Break up FAQ (#276) * DOCSP-50220: Break up FAQ * edits * RM feedback * AB feedback * fix highlight * DOCSP-50960: Install with pie (#278) * DOCSP-50960: Install with pie * edits * RR feedback * JT feedback * DOCSP-51123: CC edits and cleanup (#279) * DOCSP-51123: CC edits and cleanup * build * composer * code errors * commas * more phpcs errors * edits * phpcs * code fixes * more phpcs * fix * RR feedback * DOCSP-50772: isView() (#281) * DOCSP-50772: isView() * fix manual link Co-authored-by: Nora Reidy <[email protected]> --------- Co-authored-by: Nora Reidy <[email protected]> * phpcs * vale * use toc labels/titles * more titles * label * Drop psalm analysis for doc examples * AB feedback * filter * title changes * build errors --------- Co-authored-by: Andreas Braun <[email protected]> Co-authored-by: Rea Rustagi <[email protected]> (cherry picked from commit 70a7512) (cherry picked from commit f11a732) * build errors * remove isView --------- Co-authored-by: Andreas Braun <[email protected]> Co-authored-by: Rea Rustagi <[email protected]>
Pull Request Info
PR Reviewing Guidelines
Edits the existing BSON page for style guide alignment and adds some content.
JIRA - https://jira.mongodb.org/browse/DOCSP-47059
Staging Links
Self-Review Checklist