Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in
Toggle navigation
M
mongo-php-library
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
sinan
mongo-php-library
Commits
c1a8bbc4
Commit
c1a8bbc4
authored
Apr 10, 2018
by
Jeremy Mikola
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'v1.3'
parents
6ea28301
8c1c1f1c
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
433 additions
and
3 deletions
+433
-3
enumeration-classes.txt
docs/reference/enumeration-classes.txt
+1
-1
MongoDBModelCollectionInfo-getCappedMax.txt
...erence/method/MongoDBModelCollectionInfo-getCappedMax.txt
+22
-0
MongoDBModelCollectionInfo-getCappedSize.txt
...rence/method/MongoDBModelCollectionInfo-getCappedSize.txt
+21
-0
MongoDBModelCollectionInfo-getName.txt
docs/reference/method/MongoDBModelCollectionInfo-getName.txt
+15
-0
MongoDBModelCollectionInfo-getOptions.txt
...eference/method/MongoDBModelCollectionInfo-getOptions.txt
+26
-0
MongoDBModelCollectionInfo-isCapped.txt
.../reference/method/MongoDBModelCollectionInfo-isCapped.txt
+21
-0
MongoDBModelDatabaseInfo-getName.txt
docs/reference/method/MongoDBModelDatabaseInfo-getName.txt
+15
-0
MongoDBModelDatabaseInfo-getSizeOnDisk.txt
...ference/method/MongoDBModelDatabaseInfo-getSizeOnDisk.txt
+15
-0
MongoDBModelDatabaseInfo-isEmpty.txt
docs/reference/method/MongoDBModelDatabaseInfo-isEmpty.txt
+15
-0
MongoDBModelIndexInfo-getKey.txt
docs/reference/method/MongoDBModelIndexInfo-getKey.txt
+20
-0
MongoDBModelIndexInfo-getName.txt
docs/reference/method/MongoDBModelIndexInfo-getName.txt
+17
-0
MongoDBModelIndexInfo-getNamespace.txt
docs/reference/method/MongoDBModelIndexInfo-getNamespace.txt
+17
-0
MongoDBModelIndexInfo-getVersion.txt
docs/reference/method/MongoDBModelIndexInfo-getVersion.txt
+17
-0
MongoDBModelIndexInfo-isSparse.txt
docs/reference/method/MongoDBModelIndexInfo-isSparse.txt
+17
-0
MongoDBModelIndexInfo-isTtl.txt
docs/reference/method/MongoDBModelIndexInfo-isTtl.txt
+17
-0
MongoDBModelIndexInfo-isUnique.txt
docs/reference/method/MongoDBModelIndexInfo-isUnique.txt
+17
-0
DocumentationExamplesTest.php
tests/DocumentationExamplesTest.php
+160
-2
No files found.
docs/reference/enumeration-classes.txt
View file @
c1a8bbc4
...
...
@@ -115,7 +115,7 @@ MongoDB\\Model\\IndexInfo
This class implements PHP's :php:`ArrayAccess <arrayaccess>` interface. This
provides a mechanism for accessing index fields for which there exists no
helper method. :php`isset() <isset>` may be used to check for the existence
helper method. :php
:
`isset() <isset>` may be used to check for the existence
of a field before accessing it with ``[]``.
.. note::
...
...
docs/reference/method/MongoDBModelCollectionInfo-getCappedMax.txt
View file @
c1a8bbc4
...
...
@@ -28,6 +28,28 @@ Return Values
The document limit for the capped collection. If the collection is not capped,
``null`` will be returned.
Examples
--------
.. code-block:: php
<?php
$info = new CollectionInfo([
'name' => 'foo',
'options' => [
'capped' => true,
'size' => 1048576,
'max' => 100,
]
]);
var_dump($info->getCappedMax());
The output would then resemble::
int(100)
See Also
--------
...
...
docs/reference/method/MongoDBModelCollectionInfo-getCappedSize.txt
View file @
c1a8bbc4
...
...
@@ -29,6 +29,27 @@ Return Values
The size limit for the capped collection in bytes. If the collection is not
capped, ``null`` will be returned.
Examples
--------
.. code-block:: php
<?php
$info = new CollectionInfo([
'name' => 'foo',
'options' => [
'capped' => true,
'size' => 1048576,
]
]);
var_dump($info->getCappedSize());
The output would then resemble::
int(1048576)
See Also
--------
...
...
docs/reference/method/MongoDBModelCollectionInfo-getName.txt
View file @
c1a8bbc4
...
...
@@ -26,6 +26,21 @@ Return Values
The collection name.
Examples
--------
.. code-block:: php
<?php
$info = new CollectionInfo(['name' => 'foo']);
echo $info->getName();
The output would then resemble::
foo
See Also
--------
...
...
docs/reference/method/MongoDBModelCollectionInfo-getOptions.txt
View file @
c1a8bbc4
...
...
@@ -28,6 +28,32 @@ Return Values
The collection options.
Examples
--------
.. code-block:: php
<?php
$info = new CollectionInfo([
'name' => 'foo',
'options' => [
'capped' => true,
'size' => 1048576,
]
]);
var_dump($info->getOptions());
The output would then resemble::
array(2) {
["capped"]=>
bool(true)
["size"]=>
int(1048576)
}
See Also
--------
...
...
docs/reference/method/MongoDBModelCollectionInfo-isCapped.txt
View file @
c1a8bbc4
...
...
@@ -27,6 +27,27 @@ Return Values
A boolean indicating whether the collection is a capped collection.
Examples
--------
.. code-block:: php
<?php
$info = new CollectionInfo([
'name' => 'foo',
'options' => [
'capped' => true,
'size' => 1048576,
]
]);
var_dump($info->isCapped());
The output would then resemble::
bool(true)
See Also
--------
...
...
docs/reference/method/MongoDBModelDatabaseInfo-getName.txt
View file @
c1a8bbc4
...
...
@@ -26,6 +26,21 @@ Return Values
The database name.
Examples
--------
.. code-block:: php
<?php
$info = new DatabaseInfo(['name' => 'foo']);
echo $info->getName();
The output would then resemble::
foo
See Also
--------
...
...
docs/reference/method/MongoDBModelDatabaseInfo-getSizeOnDisk.txt
View file @
c1a8bbc4
...
...
@@ -26,6 +26,21 @@ Return Values
The total size of the database file on disk in bytes.
Examples
--------
.. code-block:: php
<?php
$info = new DatabaseInfo(['sizeOnDisk' => 1048576]);
var_dump($info->getSizeOnDisk());
The output would then resemble::
int(1048576)
See Also
--------
...
...
docs/reference/method/MongoDBModelDatabaseInfo-isEmpty.txt
View file @
c1a8bbc4
...
...
@@ -26,6 +26,21 @@ Return Values
A boolean indicating whether the database has any data.
Examples
--------
.. code-block:: php
<?php
$info = new DatabaseInfo(['empty' => true]);
var_dump($info->isEmpty());
The output would then resemble::
bool(true)
See Also
--------
...
...
docs/reference/method/MongoDBModelIndexInfo-getKey.txt
View file @
c1a8bbc4
...
...
@@ -28,6 +28,26 @@ Return Values
The index specification as an associative array.
Examples
--------
.. code-block:: php
<?php
$info = new IndexInfo([
'key' => ['x' => 1],
]);
var_dump($info->getKey());
The output would then resemble::
array(1) {
["x"]=>
int(1)
}
See Also
--------
...
...
docs/reference/method/MongoDBModelIndexInfo-getName.txt
View file @
c1a8bbc4
...
...
@@ -29,6 +29,23 @@ Return Values
The index name.
Examples
--------
.. code-block:: php
<?php
$info = new IndexInfo([
'name' => 'x_1',
]);
echo $info->getName();
The output would then resemble::
x_1
See Also
--------
...
...
docs/reference/method/MongoDBModelIndexInfo-getNamespace.txt
View file @
c1a8bbc4
...
...
@@ -27,6 +27,23 @@ Return Values
The index namespace.
Examples
--------
.. code-block:: php
<?php
$info = new IndexInfo([
'ns' => 'foo.bar',
]);
echo $info->getNamespace();
The output would then resemble::
foo.bar
See Also
--------
...
...
docs/reference/method/MongoDBModelIndexInfo-getVersion.txt
View file @
c1a8bbc4
...
...
@@ -26,6 +26,23 @@ Return Values
The index version.
Examples
--------
.. code-block:: php
<?php
$info = new IndexInfo([
'v' => 1,
]);
var_dump($info->getVersion());
The output would then resemble::
int(1)
See Also
--------
...
...
docs/reference/method/MongoDBModelIndexInfo-isSparse.txt
View file @
c1a8bbc4
...
...
@@ -28,6 +28,23 @@ Return Values
A boolean indicating whether the index is a sparse index.
Examples
--------
.. code-block:: php
<?php
$info = new IndexInfo([
'sparse' => true,
]);
var_dump($info->isSparse());
The output would then resemble::
bool(true)
See Also
--------
...
...
docs/reference/method/MongoDBModelIndexInfo-isTtl.txt
View file @
c1a8bbc4
...
...
@@ -28,6 +28,23 @@ Return Values
A boolean indicating whether the index is a TTL index.
Examples
--------
.. code-block:: php
<?php
$info = new IndexInfo([
'expireAfterSeconds' => 100,
]);
var_dump($info->isTtl());
The output would then resemble::
bool(true)
See Also
--------
...
...
docs/reference/method/MongoDBModelIndexInfo-isUnique.txt
View file @
c1a8bbc4
...
...
@@ -28,6 +28,23 @@ Return Values
A boolean indicating whether the index is a unique index.
Examples
--------
.. code-block:: php
<?php
$info = new IndexInfo([
'unique' => true,
]);
var_dump($info->isUnique());
The output would then resemble::
bool(true)
See Also
--------
...
...
tests/DocumentationExamplesTest.php
View file @
c1a8bbc4
...
...
@@ -851,8 +851,6 @@ class DocumentationExamplesTest extends FunctionalTestCase
$this
->
assertCursorCount
(
1
,
$cursor
);
}
public
function
testExample_55_58
()
{
$db
=
new
Database
(
$this
->
manager
,
$this
->
getDatabaseName
());
...
...
@@ -1022,6 +1020,166 @@ class DocumentationExamplesTest extends FunctionalTestCase
$this
->
assertNull
(
$nextChange
);
}
public
function
testAggregation_example_1
()
{
$db
=
new
Database
(
$this
->
manager
,
$this
->
getDatabaseName
());
// Start Aggregation Example 1
$cursor
=
$db
->
sales
->
aggregate
([
[
'$match'
=>
[
'items.fruit'
=>
'banana'
]],
[
'$sort'
=>
[
'date'
=>
1
]],
]);
// End Aggregation Example 1
$this
->
assertInstanceOf
(
'MongoDB\Driver\Cursor'
,
$cursor
);
}
public
function
testAggregation_example_2
()
{
$db
=
new
Database
(
$this
->
manager
,
$this
->
getDatabaseName
());
// Start Aggregation Example 2
$cursor
=
$db
->
sales
->
aggregate
([
[
'$unwind'
=>
'$items'
],
[
'$match'
=>
[
'items.fruit'
=>
'banana'
]],
[
'$group'
=>
[
'_id'
=>
[
'day'
=>
[
'$dayOfWeek'
=>
'$date'
]],
'count'
=>
[
'$sum'
=>
'$items.quantity'
]],
],
[
'$project'
=>
[
'dayOfWeek'
=>
'$_id.day'
,
'numberSold'
=>
'$count'
,
'_id'
=>
0
,
]
],
[
'$sort'
=>
[
'numberSold'
=>
1
]],
]);
// End Aggregation Example 2
$this
->
assertInstanceOf
(
'MongoDB\Driver\Cursor'
,
$cursor
);
}
public
function
testAggregation_example_3
()
{
$db
=
new
Database
(
$this
->
manager
,
$this
->
getDatabaseName
());
// Start Aggregation Example 3
$cursor
=
$db
->
sales
->
aggregate
([
[
'$unwind'
=>
'$items'
],
[
'$group'
=>
[
'_id'
=>
[
'day'
=>
[
'$dayOfWeek'
=>
'$date'
]],
'items_sold'
=>
[
'$sum'
=>
'$items.quantity'
],
'revenue'
=>
[
'$sum'
=>
[
'$multiply'
=>
[
'$items.quantity'
,
'$items.price'
]
]
],
]],
[
'$project'
=>
[
'day'
=>
'$_id.day'
,
'revenue'
=>
1
,
'items_sold'
=>
1
,
'discount'
=>
[
'$cond'
=>
[
'if'
=>
[
'$lte'
=>
[
'$revenue'
,
250
]],
'then'
=>
25
,
'else'
=>
0
,
]
],
]],
]);
// End Aggregation Example 3
$this
->
assertInstanceOf
(
'MongoDB\Driver\Cursor'
,
$cursor
);
}
public
function
testAggregation_example_4
()
{
if
(
version_compare
(
$this
->
getServerVersion
(),
'3.6.0'
,
'<'
))
{
$this
->
markTestSkipped
(
'$lookup does not support "let" option'
);
}
$db
=
new
Database
(
$this
->
manager
,
$this
->
getDatabaseName
());
// Start Aggregation Example 4
$cursor
=
$db
->
air_alliances
->
aggregate
([
[
'$lookup'
=>
[
'from'
=>
'air_airlines'
,
'let'
=>
[
'constituents'
=>
'$airlines'
],
'pipeline'
=>
[[
'$match'
=>
[
'$expr'
=>
[
'$in'
=>
[
'$name'
,
'$constituents'
]]
]]],
'as'
=>
'airlines'
,
]],
[
'$project'
=>
[
'_id'
=>
0
,
'name'
=>
1
,
'airlines'
=>
[
'$filter'
=>
[
'input'
=>
'$airlines'
,
'as'
=>
'airline'
,
'cond'
=>
[
'$eq'
=>
[
'$$airline.country'
,
'Canada'
]],
]
],
]],
]);
// End Aggregation Example 4
$this
->
assertInstanceOf
(
'MongoDB\Driver\Cursor'
,
$cursor
);
}
public
function
testRunCommand_example_1
()
{
$db
=
new
Database
(
$this
->
manager
,
$this
->
getDatabaseName
());
// Start runCommand Example 1
$cursor
=
$db
->
command
([
'buildInfo'
=>
1
]);
$result
=
$cursor
->
toArray
()[
0
];
// End runCommand Example 1
$this
->
assertInstanceOf
(
'MongoDB\Driver\Cursor'
,
$cursor
);
}
public
function
testRunCommand_example_2
()
{
$db
=
new
Database
(
$this
->
manager
,
$this
->
getDatabaseName
());
$db
->
dropCollection
(
'restaurants'
);
$db
->
createCollection
(
'restaurants'
);
// Start runCommand Example 2
$cursor
=
$db
->
command
([
'collStats'
=>
'restaurants'
]);
$result
=
$cursor
->
toArray
()[
0
];
// End runCommand Example 2
$this
->
assertInstanceOf
(
'MongoDB\Driver\Cursor'
,
$cursor
);
}
public
function
testIndex_example_1
()
{
$db
=
new
Database
(
$this
->
manager
,
$this
->
getDatabaseName
());
// Start Index Example 1
$indexName
=
$db
->
records
->
createIndex
([
'score'
=>
1
]);
// End Index Example 1
$this
->
assertEquals
(
'score_1'
,
$indexName
);
}
public
function
testIndex_example_2
()
{
$db
=
new
Database
(
$this
->
manager
,
$this
->
getDatabaseName
());
// Start Index Example 2
$indexName
=
$db
->
restaurants
->
createIndex
(
[
'cuisine'
=>
1
,
'name'
=>
1
],
[
'partialFilterExpression'
=>
[
'rating'
=>
[
'$gt'
=>
5
]]]
);
// End Index Example 2
$this
->
assertEquals
(
'cuisine_1_name_1'
,
$indexName
);
}
/**
* Return the test collection name.
*
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment