Skip to content

Commit e98f22a

Browse files
authored
PHPLIB-675 Document new CollectionInfo methods (#841)
* Document deprecation of capped collection helpers * Add detail about where collection information comes from * Document new CollectionInfo helpers * Address review feedback * Fix wrong backticks
1 parent 1685ebc commit e98f22a

9 files changed

+209
-2
lines changed

docs/reference/enumeration-classes.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,8 +43,11 @@ Methods
4343

4444
/reference/method/MongoDBModelCollectionInfo-getCappedMax
4545
/reference/method/MongoDBModelCollectionInfo-getCappedSize
46+
/reference/method/MongoDBModelCollectionInfo-getIdIndex
47+
/reference/method/MongoDBModelCollectionInfo-getInfo
4648
/reference/method/MongoDBModelCollectionInfo-getName
4749
/reference/method/MongoDBModelCollectionInfo-getOptions
50+
/reference/method/MongoDBModelCollectionInfo-getType
4851
/reference/method/MongoDBModelCollectionInfo-isCapped
4952

5053
----

docs/reference/method/MongoDBModelCollectionInfo-getCappedMax.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
MongoDB\\Model\\CollectionInfo::getCappedMax()
33
==============================================
44

5+
.. deprecated:: 1.9
6+
57
.. default-domain:: mongodb
68

79
.. contents:: On this page
@@ -28,6 +30,10 @@ Return Values
2830
The document limit for the capped collection. If the collection is not capped,
2931
``null`` will be returned.
3032

33+
This method is deprecated in favor of using
34+
:phpmethod:`MongoDB\\Model\\CollectionInfo::getOptions()` and accessing the
35+
``max`` key.
36+
3137
Examples
3238
--------
3339

docs/reference/method/MongoDBModelCollectionInfo-getCappedSize.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
MongoDB\\Model\\CollectionInfo::getCappedSize()
33
===============================================
44

5+
.. deprecated:: 1.9
6+
57
.. default-domain:: mongodb
68

79
.. contents:: On this page
@@ -29,6 +31,10 @@ Return Values
2931
The size limit for the capped collection in bytes. If the collection is not
3032
capped, ``null`` will be returned.
3133

34+
This method is deprecated in favor of using
35+
:phpmethod:`MongoDB\\Model\\CollectionInfo::getOptions()` and accessing the
36+
``size`` key.
37+
3238
Examples
3339
--------
3440

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
============================================
2+
MongoDB\\Model\\CollectionInfo::getIdIndex()
3+
============================================
4+
5+
.. versionadded:: 1.9
6+
7+
.. default-domain:: mongodb
8+
9+
.. contents:: On this page
10+
:local:
11+
:backlinks: none
12+
:depth: 1
13+
:class: singlecol
14+
15+
Definition
16+
----------
17+
18+
.. phpmethod:: MongoDB\\Model\\CollectionInfo::getIdIndex()
19+
20+
Returns information about the ``_id`` field index.
21+
22+
.. code-block:: php
23+
24+
function getIdIndex(): array
25+
26+
Return Values
27+
-------------
28+
29+
An array containing information on the ``_id`` index. This corresponds to the
30+
``idIndex`` field returned in the ``listCollections`` command reply.
31+
32+
Examples
33+
--------
34+
35+
.. code-block:: php
36+
37+
<?php
38+
39+
$info = new CollectionInfo([
40+
'type' => 'view',
41+
'name' => 'foo',
42+
'idIndex' => [
43+
'v' => 2,
44+
'key' => ['_id' => 1],
45+
'name' => '_id',
46+
'ns' => 'test.foo',
47+
],
48+
]);
49+
50+
var_dump($info->getIdIndex());
51+
52+
The output would then resemble::
53+
54+
array(4) {
55+
["v"]=>
56+
int(2)
57+
["key"]=>
58+
array(1) {
59+
["_id"]=>
60+
int(1)
61+
}
62+
["name"]=>
63+
string(3) "_id"
64+
["ns"]=>
65+
string(8) "test.foo"
66+
}
67+
68+
See Also
69+
--------
70+
71+
- :phpmethod:`MongoDB\\Database::createCollection()`
72+
- :manual:`listCollections </reference/command/listCollections>` command
73+
reference in the MongoDB manual
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
=========================================
2+
MongoDB\\Model\\CollectionInfo::getInfo()
3+
=========================================
4+
5+
.. versionadded:: 1.9
6+
7+
.. default-domain:: mongodb
8+
9+
.. contents:: On this page
10+
:local:
11+
:backlinks: none
12+
:depth: 1
13+
:class: singlecol
14+
15+
Definition
16+
----------
17+
18+
.. phpmethod:: MongoDB\\Model\\CollectionInfo::getInfo()
19+
20+
Returns additional information about the collection.
21+
22+
.. code-block:: php
23+
24+
function getInfo(): array
25+
26+
Return Values
27+
-------------
28+
29+
An array containing extra information about the collection. This corresponds to
30+
the ``info`` field returned in the ``listCollections`` command reply.
31+
32+
Examples
33+
--------
34+
35+
.. code-block:: php
36+
37+
<?php
38+
39+
$info = new CollectionInfo([
40+
'type' => 'view',
41+
'name' => 'foo',
42+
'info' => ['readOnly' => true]
43+
]);
44+
45+
var_dump($info->getInfo());
46+
47+
The output would then resemble::
48+
49+
array(1) {
50+
["readOnly"]=>
51+
bool(true)
52+
}
53+
54+
See Also
55+
--------
56+
57+
- :phpmethod:`MongoDB\\Database::createCollection()`
58+
- :manual:`listCollections </reference/command/listCollections>` command
59+
reference in the MongoDB manual

docs/reference/method/MongoDBModelCollectionInfo-getName.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ Definition
2424
Return Values
2525
-------------
2626

27-
The collection name.
27+
The collection name. This corresponds to the ``name`` field returned in the
28+
``listCollections`` command reply.
2829

2930
Examples
3031
--------

docs/reference/method/MongoDBModelCollectionInfo-getOptions.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ Definition
2626
Return Values
2727
-------------
2828

29-
The collection options.
29+
The collection options. This corresponds to the ``options`` field returned in
30+
the ``listCollections`` command reply.
3031

3132
Examples
3233
--------
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
=========================================
2+
MongoDB\\Model\\CollectionInfo::getType()
3+
=========================================
4+
5+
.. versionadded:: 1.9
6+
7+
.. default-domain:: mongodb
8+
9+
.. contents:: On this page
10+
:local:
11+
:backlinks: none
12+
:depth: 1
13+
:class: singlecol
14+
15+
Definition
16+
----------
17+
18+
.. phpmethod:: MongoDB\\Model\\CollectionInfo::getType()
19+
20+
Return the collection type.
21+
22+
.. code-block:: php
23+
24+
function getType(): string
25+
26+
Return Values
27+
-------------
28+
29+
The collection type. This corresponds to the ``type`` field returned in the
30+
``listCollections`` command reply.
31+
32+
Examples
33+
--------
34+
35+
.. code-block:: php
36+
37+
<?php
38+
39+
$info = new CollectionInfo(['type' => 'collection', 'name' => 'foo']);
40+
41+
echo $info->getType();
42+
43+
The output would then resemble::
44+
45+
collection
46+
47+
See Also
48+
--------
49+
50+
- :phpmethod:`MongoDB\\Database::createCollection()`
51+
- :manual:`listCollections </reference/command/listCollections>` command
52+
reference in the MongoDB manual

docs/reference/method/MongoDBModelCollectionInfo-isCapped.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
MongoDB\\Model\\CollectionInfo::isCapped()
33
==========================================
44

5+
.. deprecated:: 1.9
6+
57
.. default-domain:: mongodb
68

79
.. contents:: On this page
@@ -27,6 +29,10 @@ Return Values
2729

2830
A boolean indicating whether the collection is a capped collection.
2931

32+
This method is deprecated in favor of using
33+
:phpmethod:`MongoDB\\Model\\CollectionInfo::getOptions()` and accessing the
34+
``capped`` key.
35+
3036
Examples
3137
--------
3238

0 commit comments

Comments
 (0)