Skip to content

Commit a475d13

Browse files
committed
PHPLIB-278: Add examples for calling methods on database, collection, and index models
1 parent b7c4df4 commit a475d13

15 files changed

+272
-0
lines changed

source/reference/method/MongoDBModelCollectionInfo-getCappedMax.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,28 @@ Return Values
2828
The document limit for the capped collection. If the collection is not capped,
2929
``null`` will be returned.
3030

31+
Examples
32+
--------
33+
34+
.. code-block:: php
35+
36+
<?php
37+
38+
$info = new CollectionInfo([
39+
'name' => 'foo',
40+
'options' => [
41+
'capped' => true,
42+
'size' => 1048576,
43+
'max' => 100,
44+
]
45+
]);
46+
47+
var_dump($info->getCappedMax());
48+
49+
The output would then resemble::
50+
51+
int(100)
52+
3153
See Also
3254
--------
3355

source/reference/method/MongoDBModelCollectionInfo-getCappedSize.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,27 @@ Return Values
2929
The size limit for the capped collection in bytes. If the collection is not
3030
capped, ``null`` will be returned.
3131

32+
Examples
33+
--------
34+
35+
.. code-block:: php
36+
37+
<?php
38+
39+
$info = new CollectionInfo([
40+
'name' => 'foo',
41+
'options' => [
42+
'capped' => true,
43+
'size' => 1048576,
44+
]
45+
]);
46+
47+
var_dump($info->getCappedSize());
48+
49+
The output would then resemble::
50+
51+
int(1048576)
52+
3253
See Also
3354
--------
3455

source/reference/method/MongoDBModelCollectionInfo-getName.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,21 @@ Return Values
2626

2727
The collection name.
2828

29+
Examples
30+
--------
31+
32+
.. code-block:: php
33+
34+
<?php
35+
36+
$info = new CollectionInfo(['name' => 'foo']);
37+
38+
echo $info->getName();
39+
40+
The output would then resemble::
41+
42+
foo
43+
2944
See Also
3045
--------
3146

source/reference/method/MongoDBModelCollectionInfo-getOptions.txt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,32 @@ Return Values
2828

2929
The collection options.
3030

31+
Examples
32+
--------
33+
34+
.. code-block:: php
35+
36+
<?php
37+
38+
$info = new CollectionInfo([
39+
'name' => 'foo',
40+
'options' => [
41+
'capped' => true,
42+
'size' => 1048576,
43+
]
44+
]);
45+
46+
var_dump($info->getOptions());
47+
48+
The output would then resemble::
49+
50+
array(2) {
51+
["capped"]=>
52+
bool(true)
53+
["size"]=>
54+
int(1048576)
55+
}
56+
3157
See Also
3258
--------
3359

source/reference/method/MongoDBModelCollectionInfo-isCapped.txt

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,27 @@ Return Values
2727

2828
A boolean indicating whether the collection is a capped collection.
2929

30+
Examples
31+
--------
32+
33+
.. code-block:: php
34+
35+
<?php
36+
37+
$info = new CollectionInfo([
38+
'name' => 'foo',
39+
'options' => [
40+
'capped' => true,
41+
'size' => 1048576,
42+
]
43+
]);
44+
45+
var_dump($info->isCapped());
46+
47+
The output would then resemble::
48+
49+
bool(true)
50+
3051
See Also
3152
--------
3253

source/reference/method/MongoDBModelDatabaseInfo-getName.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,21 @@ Return Values
2626

2727
The database name.
2828

29+
Examples
30+
--------
31+
32+
.. code-block:: php
33+
34+
<?php
35+
36+
$info = new DatabaseInfo(['name' => 'foo']);
37+
38+
echo $info->getName();
39+
40+
The output would then resemble::
41+
42+
foo
43+
2944
See Also
3045
--------
3146

source/reference/method/MongoDBModelDatabaseInfo-getSizeOnDisk.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,21 @@ Return Values
2626

2727
The total size of the database file on disk in bytes.
2828

29+
Examples
30+
--------
31+
32+
.. code-block:: php
33+
34+
<?php
35+
36+
$info = new DatabaseInfo(['sizeOnDisk' => 1048576]);
37+
38+
var_dump($info->getSizeOnDisk());
39+
40+
The output would then resemble::
41+
42+
int(1048576)
43+
2944
See Also
3045
--------
3146

source/reference/method/MongoDBModelDatabaseInfo-isEmpty.txt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,21 @@ Return Values
2626

2727
A boolean indicating whether the database has any data.
2828

29+
Examples
30+
--------
31+
32+
.. code-block:: php
33+
34+
<?php
35+
36+
$info = new DatabaseInfo(['empty' => true]);
37+
38+
var_dump($info->isEmpty());
39+
40+
The output would then resemble::
41+
42+
bool(true)
43+
2944
See Also
3045
--------
3146

source/reference/method/MongoDBModelIndexInfo-getKey.txt

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,26 @@ Return Values
2828

2929
The index specification as an associative array.
3030

31+
Examples
32+
--------
33+
34+
.. code-block:: php
35+
36+
<?php
37+
38+
$info = new IndexInfo([
39+
'key' => ['x' => 1],
40+
]);
41+
42+
var_dump($info->getKey());
43+
44+
The output would then resemble::
45+
46+
array(1) {
47+
["x"]=>
48+
int(1)
49+
}
50+
3151
See Also
3252
--------
3353

source/reference/method/MongoDBModelIndexInfo-getName.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,23 @@ Return Values
2929

3030
The index name.
3131

32+
Examples
33+
--------
34+
35+
.. code-block:: php
36+
37+
<?php
38+
39+
$info = new IndexInfo([
40+
'name' => 'x_1',
41+
]);
42+
43+
echo $info->getName();
44+
45+
The output would then resemble::
46+
47+
x_1
48+
3249
See Also
3350
--------
3451

source/reference/method/MongoDBModelIndexInfo-getNamespace.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,23 @@ Return Values
2727

2828
The index namespace.
2929

30+
Examples
31+
--------
32+
33+
.. code-block:: php
34+
35+
<?php
36+
37+
$info = new IndexInfo([
38+
'ns' => 'foo.bar',
39+
]);
40+
41+
echo $info->getNamespace();
42+
43+
The output would then resemble::
44+
45+
foo.bar
46+
3047
See Also
3148
--------
3249

source/reference/method/MongoDBModelIndexInfo-getVersion.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,23 @@ Return Values
2626

2727
The index version.
2828

29+
Examples
30+
--------
31+
32+
.. code-block:: php
33+
34+
<?php
35+
36+
$info = new IndexInfo([
37+
'v' => 1,
38+
]);
39+
40+
var_dump($info->getVersion());
41+
42+
The output would then resemble::
43+
44+
int(1)
45+
2946
See Also
3047
--------
3148

source/reference/method/MongoDBModelIndexInfo-isSparse.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,23 @@ Return Values
2828

2929
A boolean indicating whether the index is a sparse index.
3030

31+
Examples
32+
--------
33+
34+
.. code-block:: php
35+
36+
<?php
37+
38+
$info = new IndexInfo([
39+
'sparse' => true,
40+
]);
41+
42+
var_dump($info->isSparse());
43+
44+
The output would then resemble::
45+
46+
bool(true)
47+
3148
See Also
3249
--------
3350

source/reference/method/MongoDBModelIndexInfo-isTtl.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,23 @@ Return Values
2828

2929
A boolean indicating whether the index is a TTL index.
3030

31+
Examples
32+
--------
33+
34+
.. code-block:: php
35+
36+
<?php
37+
38+
$info = new IndexInfo([
39+
'expireAfterSeconds' => 100,
40+
]);
41+
42+
var_dump($info->isTtl());
43+
44+
The output would then resemble::
45+
46+
bool(true)
47+
3148
See Also
3249
--------
3350

source/reference/method/MongoDBModelIndexInfo-isUnique.txt

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,23 @@ Return Values
2828

2929
A boolean indicating whether the index is a unique index.
3030

31+
Examples
32+
--------
33+
34+
.. code-block:: php
35+
36+
<?php
37+
38+
$info = new IndexInfo([
39+
'unique' => true,
40+
]);
41+
42+
var_dump($info->isUnique());
43+
44+
The output would then resemble::
45+
46+
bool(true)
47+
3148
See Also
3249
--------
3350

0 commit comments

Comments
 (0)