-
Notifications
You must be signed in to change notification settings - Fork 266
PHPLIB-675 Document new CollectionInfo methods #841
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
Changes from all commits
4416beb
b81294c
9b4d103
e7dfb43
022a319
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
============================================ | ||
MongoDB\\Model\\CollectionInfo::getIdIndex() | ||
============================================ | ||
|
||
.. versionadded:: 1.9 | ||
|
||
.. default-domain:: mongodb | ||
|
||
.. contents:: On this page | ||
:local: | ||
:backlinks: none | ||
:depth: 1 | ||
:class: singlecol | ||
|
||
Definition | ||
---------- | ||
|
||
.. phpmethod:: MongoDB\\Model\\CollectionInfo::getIdIndex() | ||
|
||
Returns information about the ``_id`` field index. | ||
|
||
.. code-block:: php | ||
|
||
function getIdIndex(): array | ||
|
||
Return Values | ||
------------- | ||
|
||
An array containing information on the ``_id`` index. This corresponds to the | ||
``idIndex`` field returned in the ``listCollections`` command reply. | ||
|
||
Examples | ||
-------- | ||
|
||
.. code-block:: php | ||
|
||
<?php | ||
|
||
$info = new CollectionInfo([ | ||
'type' => 'view', | ||
'name' => 'foo', | ||
'idIndex' => [ | ||
'v' => 2, | ||
'key' => ['_id' => 1], | ||
'name' => '_id', | ||
'ns' => 'test.foo', | ||
], | ||
]); | ||
|
||
var_dump($info->getIdIndex()); | ||
Comment on lines
+39
to
+50
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm not sure if these examples are really helpful. I believe we could optimise these by creating a collection first, then getting a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I concur. There's absolutely no reason to construct this directly, as that's not the intended use of this API. It looks like these examples date back to PHPLIB-278, which I signed off on. In the meantime, I'd suggest not adding any new examples and making a ticket to either replace all of these with integration examples or remove them entirely and just point users to the corresponding enumeration method that would return these objects in the first place. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll leave these examples in for consistency and have created PHPLIB-689 to track improvements. |
||
|
||
The output would then resemble:: | ||
|
||
array(4) { | ||
["v"]=> | ||
int(2) | ||
["key"]=> | ||
array(1) { | ||
["_id"]=> | ||
int(1) | ||
} | ||
["name"]=> | ||
string(3) "_id" | ||
["ns"]=> | ||
string(8) "test.foo" | ||
} | ||
|
||
See Also | ||
-------- | ||
|
||
- :phpmethod:`MongoDB\\Database::createCollection()` | ||
- :manual:`listCollections </reference/command/listCollections>` command | ||
reference in the MongoDB manual |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
========================================= | ||
MongoDB\\Model\\CollectionInfo::getInfo() | ||
========================================= | ||
|
||
.. versionadded:: 1.9 | ||
|
||
.. default-domain:: mongodb | ||
jmikola marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
.. contents:: On this page | ||
:local: | ||
:backlinks: none | ||
:depth: 1 | ||
:class: singlecol | ||
|
||
Definition | ||
---------- | ||
|
||
.. phpmethod:: MongoDB\\Model\\CollectionInfo::getInfo() | ||
|
||
Returns additional information about the collection. | ||
|
||
.. code-block:: php | ||
|
||
function getInfo(): array | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I had a thought about how this and |
||
|
||
Return Values | ||
------------- | ||
|
||
An array containing extra information about the collection. This corresponds to | ||
the ``info`` field returned in the ``listCollections`` command reply. | ||
|
||
Examples | ||
-------- | ||
|
||
.. code-block:: php | ||
|
||
<?php | ||
|
||
$info = new CollectionInfo([ | ||
'type' => 'view', | ||
'name' => 'foo', | ||
'info' => ['readOnly' => true] | ||
]); | ||
|
||
var_dump($info->getInfo()); | ||
|
||
The output would then resemble:: | ||
|
||
array(1) { | ||
["readOnly"]=> | ||
bool(true) | ||
} | ||
|
||
See Also | ||
-------- | ||
|
||
- :phpmethod:`MongoDB\\Database::createCollection()` | ||
- :manual:`listCollections </reference/command/listCollections>` command | ||
reference in the MongoDB manual |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
========================================= | ||
MongoDB\\Model\\CollectionInfo::getType() | ||
========================================= | ||
|
||
.. versionadded:: 1.9 | ||
|
||
.. default-domain:: mongodb | ||
jmikola marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
.. contents:: On this page | ||
:local: | ||
:backlinks: none | ||
:depth: 1 | ||
:class: singlecol | ||
|
||
Definition | ||
---------- | ||
|
||
.. phpmethod:: MongoDB\\Model\\CollectionInfo::getType() | ||
|
||
Return the collection type. | ||
|
||
.. code-block:: php | ||
|
||
function getType(): string | ||
|
||
Return Values | ||
------------- | ||
|
||
The collection type. This corresponds to the ``type`` field returned in the | ||
``listCollections`` command reply. | ||
|
||
Examples | ||
-------- | ||
|
||
.. code-block:: php | ||
|
||
<?php | ||
|
||
$info = new CollectionInfo(['type' => 'collection', 'name' => 'foo']); | ||
|
||
echo $info->getType(); | ||
|
||
The output would then resemble:: | ||
|
||
collection | ||
|
||
See Also | ||
-------- | ||
|
||
- :phpmethod:`MongoDB\\Database::createCollection()` | ||
- :manual:`listCollections </reference/command/listCollections>` command | ||
reference in the MongoDB manual |
Uh oh!
There was an error while loading. Please reload this page.