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
b33e5a5a
Commit
b33e5a5a
authored
Oct 28, 2016
by
Jeremy Mikola
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update MongoDB\Collection documentation
parent
b12430a8
Show whitespace changes
Inline
Side-by-side
Showing
63 changed files
with
1037 additions
and
1128 deletions
+1037
-1128
apiargs-MongoDBCollection-method-aggregate-option.yaml
...es/apiargs-MongoDBCollection-method-aggregate-option.yaml
+31
-21
apiargs-MongoDBCollection-method-aggregate-param.yaml
...des/apiargs-MongoDBCollection-method-aggregate-param.yaml
+4
-4
apiargs-MongoDBCollection-method-bulkWrite-option.yaml
...es/apiargs-MongoDBCollection-method-bulkWrite-option.yaml
+10
-9
apiargs-MongoDBCollection-method-bulkWrite-param.yaml
...des/apiargs-MongoDBCollection-method-bulkWrite-param.yaml
+17
-15
apiargs-MongoDBCollection-method-construct-option.yaml
...es/apiargs-MongoDBCollection-method-construct-option.yaml
+49
-0
apiargs-MongoDBCollection-method-construct-param.yaml
...des/apiargs-MongoDBCollection-method-construct-param.yaml
+7
-17
apiargs-MongoDBCollection-method-count-option.yaml
...cludes/apiargs-MongoDBCollection-method-count-option.yaml
+9
-7
apiargs-MongoDBCollection-method-count-param.yaml
...ncludes/apiargs-MongoDBCollection-method-count-param.yaml
+2
-2
apiargs-MongoDBCollection-method-createIndex-option.yaml
.../apiargs-MongoDBCollection-method-createIndex-option.yaml
+10
-26
apiargs-MongoDBCollection-method-createIndex-param.yaml
...s/apiargs-MongoDBCollection-method-createIndex-param.yaml
+6
-7
apiargs-MongoDBCollection-method-drop-option.yaml
...ncludes/apiargs-MongoDBCollection-method-drop-option.yaml
+1
-1
apiargs-MongoDBCollection-method-drop-param.yaml
...includes/apiargs-MongoDBCollection-method-drop-param.yaml
+1
-1
apiargs-MongoDBCollection-method-dropIndex-option.yaml
...es/apiargs-MongoDBCollection-method-dropIndex-option.yaml
+1
-1
apiargs-MongoDBCollection-method-dropIndex-param.yaml
...des/apiargs-MongoDBCollection-method-dropIndex-param.yaml
+1
-1
apiargs-MongoDBCollection-method-dropIndexes-option.yaml
.../apiargs-MongoDBCollection-method-dropIndexes-option.yaml
+1
-1
apiargs-MongoDBCollection-method-dropIndexes-param.yaml
...s/apiargs-MongoDBCollection-method-dropIndexes-param.yaml
+1
-1
apiargs-MongoDBCollection-method-find-option.yaml
...ncludes/apiargs-MongoDBCollection-method-find-option.yaml
+17
-18
apiargs-MongoDBCollection-method-findOne-option.yaml
...udes/apiargs-MongoDBCollection-method-findOne-option.yaml
+1
-1
apiargs-MongoDBCollection-method-findOneAndDelete-option.yaml
...rgs-MongoDBCollection-method-findOneAndDelete-option.yaml
+1
-1
apiargs-MongoDBCollection-method-findOneAndReplace-option.yaml
...gs-MongoDBCollection-method-findOneAndReplace-option.yaml
+13
-5
apiargs-MongoDBCollection-method-findOneAndUpdate-option.yaml
...rgs-MongoDBCollection-method-findOneAndUpdate-option.yaml
+6
-8
apiargs-MongoDBCollection-method-insertMany-option.yaml
...s/apiargs-MongoDBCollection-method-insertMany-option.yaml
+1
-1
apiargs-MongoDBCollection-method-insertMany-param.yaml
...es/apiargs-MongoDBCollection-method-insertMany-param.yaml
+1
-1
apiargs-MongoDBCollection-method-insertOne-option.yaml
...es/apiargs-MongoDBCollection-method-insertOne-option.yaml
+1
-1
apiargs-MongoDBCollection-method-insertOne-param.yaml
...des/apiargs-MongoDBCollection-method-insertOne-param.yaml
+1
-1
apiargs-MongoDBCollection-method-replaceOne-option.yaml
...s/apiargs-MongoDBCollection-method-replaceOne-option.yaml
+1
-1
apiargs-MongoDBCollection-method-updateMany-option.yaml
...s/apiargs-MongoDBCollection-method-updateMany-option.yaml
+1
-1
apiargs-MongoDBCollection-method-updateOne-option.yaml
...es/apiargs-MongoDBCollection-method-updateOne-option.yaml
+1
-1
apiargs-MongoDBCollection-method-withOptions-option.yaml
.../apiargs-MongoDBCollection-method-withOptions-option.yaml
+1
-1
apiargs-common-option.yaml
docs/includes/apiargs-common-option.yaml
+1
-1
apiargs-common-param.yaml
docs/includes/apiargs-common-param.yaml
+4
-4
example-insertOne.rst
docs/includes/example-insertOne.rst
+0
-64
extracts-bson-deserialization-base.yaml
docs/includes/extracts-bson-deserialization-base.yaml
+5
-6
extracts-bson-deserialization.yaml
docs/includes/extracts-bson-deserialization.yaml
+3
-3
MongoDBCollection-aggregate.txt
docs/reference/method/MongoDBCollection-aggregate.txt
+29
-28
MongoDBCollection-bulkWrite.txt
docs/reference/method/MongoDBCollection-bulkWrite.txt
+18
-13
MongoDBCollection-count.txt
docs/reference/method/MongoDBCollection-count.txt
+12
-10
MongoDBCollection-createIndex.txt
docs/reference/method/MongoDBCollection-createIndex.txt
+51
-58
MongoDBCollection-createIndexes.txt
docs/reference/method/MongoDBCollection-createIndexes.txt
+43
-52
MongoDBCollection-deleteMany.txt
docs/reference/method/MongoDBCollection-deleteMany.txt
+15
-17
MongoDBCollection-deleteOne.txt
docs/reference/method/MongoDBCollection-deleteOne.txt
+17
-19
MongoDBCollection-distinct.txt
docs/reference/method/MongoDBCollection-distinct.txt
+24
-33
MongoDBCollection-drop.txt
docs/reference/method/MongoDBCollection-drop.txt
+27
-31
MongoDBCollection-dropIndex.txt
docs/reference/method/MongoDBCollection-dropIndex.txt
+26
-30
MongoDBCollection-dropIndexes.txt
docs/reference/method/MongoDBCollection-dropIndexes.txt
+27
-29
MongoDBCollection-find.txt
docs/reference/method/MongoDBCollection-find.txt
+34
-36
MongoDBCollection-findOne.txt
docs/reference/method/MongoDBCollection-findOne.txt
+51
-47
MongoDBCollection-findOneAndDelete.txt
docs/reference/method/MongoDBCollection-findOneAndDelete.txt
+33
-36
MongoDBCollection-findOneAndReplace.txt
.../reference/method/MongoDBCollection-findOneAndReplace.txt
+39
-40
MongoDBCollection-findOneAndUpdate.txt
docs/reference/method/MongoDBCollection-findOneAndUpdate.txt
+58
-34
MongoDBCollection-getCollectionName.txt
.../reference/method/MongoDBCollection-getCollectionName.txt
+23
-12
MongoDBCollection-getDatabaseName.txt
docs/reference/method/MongoDBCollection-getDatabaseName.txt
+24
-12
MongoDBCollection-getManager.txt
docs/reference/method/MongoDBCollection-getManager.txt
+1
-1
MongoDBCollection-getNamespace.txt
docs/reference/method/MongoDBCollection-getNamespace.txt
+24
-13
MongoDBCollection-insertMany.txt
docs/reference/method/MongoDBCollection-insertMany.txt
+34
-38
MongoDBCollection-insertOne.txt
docs/reference/method/MongoDBCollection-insertOne.txt
+47
-21
MongoDBCollection-listIndexes.txt
docs/reference/method/MongoDBCollection-listIndexes.txt
+21
-29
MongoDBCollection-replaceOne.txt
docs/reference/method/MongoDBCollection-replaceOne.txt
+34
-70
MongoDBCollection-updateMany.txt
docs/reference/method/MongoDBCollection-updateMany.txt
+33
-74
MongoDBCollection-updateOne.txt
docs/reference/method/MongoDBCollection-updateOne.txt
+35
-75
MongoDBCollection-withOptions.txt
docs/reference/method/MongoDBCollection-withOptions.txt
+23
-18
MongoDBCollection__construct.txt
docs/reference/method/MongoDBCollection__construct.txt
+17
-13
crud.txt
docs/tutorial/crud.txt
+7
-6
No files found.
docs/includes/apiargs-MongoDBCollection-method-aggregate-option.yaml
View file @
b33e5a5a
...
@@ -2,9 +2,9 @@ arg_name: option
...
@@ -2,9 +2,9 @@ arg_name: option
name
:
allowDiskUse
name
:
allowDiskUse
type
:
boolean
type
:
boolean
description
:
|
description
:
|
Enables writing to temporary files. When set to
true, aggregation
Enables writing to temporary files. When set to
``true``, aggregation stages
stages can write data to the ``_tmp`` sub-directory in the dbPath
can write data to the ``_tmp`` sub-directory in the dbPath directory.
directory.
The default is ``false``.
The default is ``false``.
interface
:
phpmethod
interface
:
phpmethod
operation
:
MongoDB\\Collection::aggregate
operation
:
MongoDB\\Collection::aggregate
optional
:
true
optional
:
true
...
@@ -21,51 +21,61 @@ optional: true
...
@@ -21,51 +21,61 @@ optional: true
position
:
2
position
:
2
---
---
source
:
source
:
ref
:
bypassDocumentValidation
file
:
apiargs-common-option.yaml
file
:
apiargs-common-option.yaml
ref
:
bypassDocumentValidation
operation
:
MongoDB\\Collection::aggregate
operation
:
MongoDB\\Collection::aggregate
position
:
5
position
:
3
---
---
source
:
source
:
ref
:
maxTimeMS
file
:
apiargs-common-option.yaml
file
:
apiargs-common-option.yaml
ref
:
maxTimeMS
operation
:
MongoDB\\Collection::aggregate
operation
:
MongoDB\\Collection::aggregate
position
:
4
position
:
4
---
---
source
:
source
:
ref
:
readConcern
file
:
apiargs-common-option.yaml
file
:
apiargs-common-option.yaml
operation
:
MongoDB\\Collection::selectDatabase
ref
:
readConcern
operation
:
MongoDB\\Collection::aggregate
position
:
5
replacement
:
replacement
:
resource
:
"
aggregation"
resource
:
"
aggregation"
position
:
5
parent
:
"
collection"
---
---
source
:
source
:
ref
:
readPreference
file
:
apiargs-common-option.yaml
file
:
apiargs-common-option.yaml
operation
:
MongoDB\\Collection::selectDatabase
ref
:
readPreference
operation
:
MongoDB\\Collection::aggregate
position
:
6
replacement
:
replacement
:
resource
:
"
aggregation"
resource
:
"
aggregation"
position
:
6
parent
:
"
collection"
---
---
source
:
source
:
ref
:
typeMap
file
:
apiargs-common-option.yaml
file
:
apiargs-common-option.yaml
operation
:
MongoDB\\Collection::selectDatabase
ref
:
typeMap
operation
:
MongoDB\\Collection::aggregate
position
:
7
position
:
7
description
:
|
Type map for BSON deserialization. This will be applied to the returned
cursor. Defaults to the collections's type map.
.. note::
This is not supported for inline aggregation results (i.e. ``useCursor``
option is ``false`` or the server version is < 2.6).
---
---
arg_name
:
param
arg_name
:
param
name
:
useCursor
name
:
useCursor
type
:
boolean
type
:
boolean
description
:
|
description
:
|
Indicates whether the command will request that the server provide
Indicates whether the command will request that the server provide
results
results
using a cursor. The default is ``true``.
using a cursor. The default is ``true``.
For MongoDB version 2.6 or later, ``useCursor`` allows users to turn
For MongoDB version 2.6 or later, ``useCursor`` allows users to turn
off
off cursors if necessary to aid in mongod/mongos
upgrades.
cursors if necessary to aid in replica set or shard cluster
upgrades.
``useCursor`` is ignored for MongoDB versions prior to 2.6 as
``useCursor`` is ignored for MongoDB versions prior to 2.6 as
aggregation
aggregation cursors are not available pre-2.6
.
cursors are not available
.
interface
:
phpmethod
interface
:
phpmethod
operation
:
MongoDB\\Collection::aggregate
operation
:
MongoDB\\Collection::aggregate
optional
:
true
optional
:
true
...
...
docs/includes/apiargs-MongoDBCollection-method-aggregate-param.yaml
View file @
b33e5a5a
...
@@ -2,15 +2,15 @@ arg_name: param
...
@@ -2,15 +2,15 @@ arg_name: param
name
:
$pipeline
name
:
$pipeline
type
:
array
type
:
array
description
:
|
description
:
|
Specifies an :manual:`aggregation pipeline </core/aggregation-pipeline>` operation.
Specifies an :manual:`aggregation pipeline </core/aggregation-pipeline>`
operation.
interface
:
phpmethod
interface
:
phpmethod
operation
:
MongoDB\\Collection::aggregate
operation
:
MongoDB\\Collection::aggregate
optional
:
true
position
:
1
position
:
1
---
---
source
:
source
:
ref
:
$options
file
:
apiargs-common-param.yaml
file
:
apiargs-common-param.yaml
ref
:
$options
operation
:
MongoDB\\Collection::aggregate
operation
:
MongoDB\\Collection::aggregate
position
:
2
position
:
2
...
...
docs/includes/apiargs-MongoDBCollection-method-bulkWrite-option.yaml
View file @
b33e5a5a
source
:
source
:
ref
:
bypassDocumentValidation
file
:
apiargs-common-option.yaml
file
:
apiargs-common-option.yaml
ref
:
bypassDocumentValidation
operation
:
MongoDB\\Collection::bulkWrite
operation
:
MongoDB\\Collection::bulkWrite
position
:
1
position
:
1
---
---
...
@@ -8,23 +8,24 @@ arg_name: option
...
@@ -8,23 +8,24 @@ arg_name: option
name
:
ordered
name
:
ordered
type
:
boolean
type
:
boolean
description
:
|
description
:
|
If ``true``: when a
n insert fails, the operation returns without performing the
If ``true``: when a
single write fails, the operation returns without
remaining writes.
performing the remaining writes.
If ``false``: when a write fails, the operation will continue with the
If ``false``: when a
single
write fails, the operation will continue with the
remaining writes, if any.
remaining writes, if any.
The default is ``true``.
The default is ``true``.
optional
:
true
interface
:
phpmethod
interface
:
phpmethod
operation
:
MongoDB\\Collection::bulkWrite
operation
:
MongoDB\\Collection::bulkWrite
optional
:
true
position
:
2
position
:
2
---
---
source
:
source
:
ref
:
writeConcern
file
:
apiargs-common-option.yaml
file
:
apiargs-common-option.yaml
ref
:
writeConcern
operation
:
MongoDB\\Collection::bulkWrite
operation
:
MongoDB\\Collection::bulkWrite
replacement
:
replacement
:
resource
:
"
write"
resource
:
"
write"
parent
:
"
collection"
position
:
3
position
:
3
...
...
docs/includes/apiargs-MongoDBCollection-method-bulkWrite-param.yaml
View file @
b33e5a5a
...
@@ -2,14 +2,15 @@ arg_name: param
...
@@ -2,14 +2,15 @@ arg_name: param
name
:
$operations
name
:
$operations
type
:
array
type
:
array
description
:
|
description
:
|
An array containing the write operations to perform. {{role}}
An array containing the write operations to perform.
supports :phpmethod:`deleteMany <MongoDB\\Collection::deleteMany>`,
:phpmethod:`MongoDB\\Collection::bulkWrite()` supports
:phpmethod:`deleteOne <MongoDB\\Collection::deleteOne>`, :phpmethod:`insertOne
:phpmethod:`deleteMany() <MongoDB\\Collection::deleteMany>`,
<MongoDB\\Collection::insertOne>`, :phpmethod:`replaceOne
:phpmethod:`deleteOne() <MongoDB\\Collection::deleteOne>`,
<MongoDB\\Collection::replaceOne>`, :phpmethod:`updateMany
:phpmethod:`insertOne() <MongoDB\\Collection::insertOne>`,
<MongoDB\\Collection::updateMany>`, and :phpmethod:`updateOne
:phpmethod:`replaceOne() <MongoDB\\Collection::replaceOne>`,
<MongoDB\\Collection::updateOne>` operations in the following array
:phpmethod:`updateMany() <MongoDB\\Collection::updateMany>`, and
structure:
:phpmethod:`updateOne() <MongoDB\\Collection::updateOne>` operations in the
following array structure:
.. code-block:: php
.. code-block:: php
...
@@ -22,17 +23,18 @@ description: |
...
@@ -22,17 +23,18 @@ description: |
[ 'updateOne' => [ $filter, $update, $options ] ],
[ 'updateOne' => [ $filter, $update, $options ] ],
]
]
post
:
|
post
:
|
Arguments correspond to the respective operation methods. However,
Arguments correspond to the respective operation methods. However, the
the ``writeConcern`` option is specified for the top-level bulk write
``writeConcern`` option is specified as a top-level option to
operation instead of each individual operation.
:phpmethod:`MongoDB\\Collection::bulkWrite()` instead of each individual
operation.
interface
:
phpmethod
interface
:
phpmethod
operation
:
MongoDB\\Collection::bulkWrite
operation
:
MongoDB\\Collection::bulkWrite
optional
:
true
optional
:
true
position
:
1
position
:
1
---
---
source
:
source
:
ref
:
$options
file
:
apiargs-common-param.yaml
file
:
apiargs-common-param.yaml
ref
:
$options
operation
:
MongoDB\\Collection::bulkWrite
operation
:
MongoDB\\Collection::bulkWrite
interface
:
phpmethod
interface
:
phpmethod
position
:
2
position
:
2
...
...
docs/includes/apiargs-MongoDBCollection-method-construct-option.yaml
0 → 100644
View file @
b33e5a5a
source
:
file
:
apiargs-common-option.yaml
ref
:
readConcern
operation
:
MongoDB\\Collection::__construct
position
:
1
replacement
:
resource
:
"
collection"
parent
:
"
manager"
---
source
:
file
:
apiargs-common-option.yaml
ref
:
readPreference
operation
:
MongoDB\\Collection::__construct
position
:
2
replacement
:
resource
:
"
collection"
parent
:
"
manager"
---
arg_name
:
option
name
:
typeMap
type
:
array
description
:
|
Default :php:`type map
<manual/en/mongodb.persistence.deserialization.php#mongodb.persistence.typemaps>`
to apply to cursors. The type map determines how BSON documents are converted
to PHP values which determines. The |php-library| uses the following type map
by default:
.. code-block:: php
[
'array' => 'MongoDB\Model\BSONArray',
'document' => 'MongoDB\Model\BSONDocument',
'root' => 'MongoDB\Model\BSONDocument',
]
interface
:
phpmethod
operation
:
MongoDB\\Collection::__construct
optional
:
true
position
:
3
---
source
:
file
:
apiargs-common-option.yaml
ref
:
writeConcern
operation
:
MongoDB\\Collection::__construct
position
:
4
replacement
:
resource
:
"
collection"
parent
:
"
manager"
...
docs/includes/apiargs-MongoDBCollection-method-construct-param.yaml
View file @
b33e5a5a
arg_name
:
param
source
:
name
:
$manager
file
:
apiargs-common-param.yaml
type
:
:php:`MongoDB\\Driver\\Manager <class.mongodb-driver-manager>`
ref
:
$manager
description
:
|
The :php:`Manager <mongodb-driver-manager>` instance from the driver.
The manager maintains connections between the driver and your MongoDB
instances.
interface
:
phpmethod
operation
:
MongoDB\\Collection::__construct
operation
:
MongoDB\\Collection::__construct
optional
:
false
position
:
1
position
:
1
---
---
source
:
source
:
ref
:
$databaseName
file
:
apiargs-common-param.yaml
file
:
apiargs-common-param.yaml
ref
:
$databaseName
operation
:
MongoDB\\Collection::__construct
operation
:
MongoDB\\Collection::__construct
replacement
:
select
:
"
"
position
:
2
position
:
2
---
---
source
:
source
:
ref
:
$collectionName
file
:
apiargs-common-param.yaml
file
:
apiargs-common-param.yaml
ref
:
$collectionName
operation
:
MongoDB\\Collection::__construct
operation
:
MongoDB\\Collection::__construct
replacement
:
select
:
"
"
position
:
3
position
:
3
---
---
source
:
source
:
ref
:
$options
file
:
apiargs-common-param.yaml
file
:
apiargs-common-param.yaml
ref
:
$options
operation
:
MongoDB\\Collection::__construct
operation
:
MongoDB\\Collection::__construct
position
:
4
position
:
4
...
...
docs/includes/apiargs-MongoDBCollection-method-count-option.yaml
View file @
b33e5a5a
arg_name
:
option
arg_name
:
option
name
:
hint
name
:
hint
type
:
string
or
array|object
type
:
string
|
array|object
description
:
|
description
:
|
The index to use. If you specify a document, it is interpreted as
The index to use. If you specify a document, it is interpreted as an index
an index specification and a name will be generated.
specification and a name will be generated.
optional
:
true
interface
:
phpmethod
interface
:
phpmethod
operation
:
MongoDB\\Collection::count
operation
:
MongoDB\\Collection::count
optional
:
true
position
:
1
position
:
1
---
---
arg_name
:
option
arg_name
:
option
...
@@ -14,14 +14,14 @@ name: limit
...
@@ -14,14 +14,14 @@ name: limit
type
:
integer
type
:
integer
description
:
|
description
:
|
The maximum number of documents to return.
The maximum number of documents to return.
optional
:
true
interface
:
phpmethod
interface
:
phpmethod
operation
:
MongoDB\\Collection::count
operation
:
MongoDB\\Collection::count
optional
:
true
position
:
2
position
:
2
---
---
source
:
source
:
ref
:
maxTimeMS
file
:
apiargs-common-option.yaml
file
:
apiargs-common-option.yaml
ref
:
maxTimeMS
operation
:
MongoDB\\Collection::count
operation
:
MongoDB\\Collection::count
position
:
3
position
:
3
---
---
...
@@ -31,6 +31,7 @@ source:
...
@@ -31,6 +31,7 @@ source:
operation
:
MongoDB\\Collection::count
operation
:
MongoDB\\Collection::count
replacement
:
replacement
:
resource
:
"
count"
resource
:
"
count"
parent
:
"
collection"
position
:
4
position
:
4
---
---
source
:
source
:
...
@@ -38,6 +39,7 @@ source:
...
@@ -38,6 +39,7 @@ source:
file
:
apiargs-common-option.yaml
file
:
apiargs-common-option.yaml
replacement
:
replacement
:
resource
:
"
count"
resource
:
"
count"
parent
:
"
collection"
position
:
5
position
:
5
---
---
arg_name
:
option
arg_name
:
option
...
@@ -45,8 +47,8 @@ name: skip
...
@@ -45,8 +47,8 @@ name: skip
type
:
integer
type
:
integer
description
:
|
description
:
|
The number of documents to skip before returning the documents.
The number of documents to skip before returning the documents.
optional
:
true
interface
:
phpmethod
interface
:
phpmethod
operation
:
MongoDB\\Collection::count
operation
:
MongoDB\\Collection::count
optional
:
true
position
:
6
position
:
6
...
...
docs/includes/apiargs-MongoDBCollection-method-count-param.yaml
View file @
b33e5a5a
source
:
source
:
ref
:
$filter
file
:
apiargs-common-param.yaml
file
:
apiargs-common-param.yaml
ref
:
$filter
operation
:
MongoDB\\Collection::count
operation
:
MongoDB\\Collection::count
position
:
1
position
:
1
---
---
source
:
source
:
ref
:
$options
file
:
apiargs-common-param.yaml
file
:
apiargs-common-param.yaml
ref
:
$options
operation
:
MongoDB\\Collection::count
operation
:
MongoDB\\Collection::count
position
:
2
position
:
2
...
...
docs/includes/apiargs-MongoDBCollection-method-createIndex-option.yaml
View file @
b33e5a5a
...
@@ -42,8 +42,8 @@ arg_name: option
...
@@ -42,8 +42,8 @@ arg_name: option
name
:
name
name
:
name
type
:
string
type
:
string
description
:
|
description
:
|
Specifies the name for the index. By default, MongoDB creates index
Specifies the name for the index. By default, MongoDB creates index
names
names
based on the key.
based on the key.
interface
:
phpmethod
interface
:
phpmethod
operation
:
MongoDB\\Collection::createIndex
operation
:
MongoDB\\Collection::createIndex
optional
:
true
optional
:
true
...
@@ -64,36 +64,20 @@ arg_name: option
...
@@ -64,36 +64,20 @@ arg_name: option
name
:
2dsphereIndexVersion
name
:
2dsphereIndexVersion
type
:
integer
type
:
integer
description
:
|
description
:
|
Specifies the :manual:`version of a 2dsphere </core/2dsphere>` index
Specifies the :manual:`version of a 2dsphere </core/2dsphere>` index
to
to
create.
create.
MongoDB 2.6 introduced version 2 of 2dsphere indexes. Version 2 is
MongoDB 2.6 introduced version 2 of 2dsphere indexes. Version 2 is the default
the default version of 2dsphere indexes created in MongoDB 2.6 and
version of 2dsphere indexes created in MongoDB 2.6 and later versions.
later series. ``2dsphereIndexVersion`` enables you to overrride the
``2dsphereIndexVersion`` enables you to overrride the default version 2.
default version 2.
interface
:
phpmethod
interface
:
phpmethod
operation
:
MongoDB\\Collection::createIndex
operation
:
MongoDB\\Collection::createIndex
optional
:
true
optional
:
true
position
:
7
position
:
7
---
---
arg_name
:
option
name
:
socketTimeoutMS
type
:
integer
description
:
|
Specifies the time limit, in milliseconds, for socket
communication. If the :program:`mongod` does not respond within the
timeout period, a ``MongoCursorTimeoutException`` is thrown and
there will be no way to determine if the server actually handled the
write or not. Specify ``-1`` to block indefinitely. The default value
is 30000 (30 seconds).
interface
:
phpmethod
operation
:
MongoDB\\Collection::createIndex
optional
:
true
position
:
8
---
source
:
source
:
ref
:
maxTimeMS
ref
:
maxTimeMS
file
:
apiargs-common-option.yaml
file
:
apiargs-common-option.yaml
operation
:
MongoDB\\Collection::createIndex
operation
:
MongoDB\\Collection::createIndex
position
:
9
position
:
8
...
...
docs/includes/apiargs-MongoDBCollection-method-createIndex-param.yaml
View file @
b33e5a5a
...
@@ -4,13 +4,12 @@ type: array|object
...
@@ -4,13 +4,12 @@ type: array|object
description
:
|
description
:
|
Specifies the field or fields to index and the index order.
Specifies the field or fields to index and the index order.
For example, the following specifies a descending index
For example, the following specifies a descending index
on the ``username``
on the ``username``
field:
field:
.. code-block:: php
.. code-block:: php
$key = [ 'username' => -1 ];
[ 'username' => -1 ]
operation
:
MongoDB\\Collection::createIndex
operation
:
MongoDB\\Collection::createIndex
interface
:
phpmethod
interface
:
phpmethod
optional
:
false
optional
:
false
...
...
docs/includes/apiargs-MongoDBCollection-method-drop-option.yaml
View file @
b33e5a5a
docs/includes/apiargs-MongoDBCollection-method-drop-param.yaml
View file @
b33e5a5a
docs/includes/apiargs-MongoDBCollection-method-dropIndex-option.yaml
View file @
b33e5a5a
docs/includes/apiargs-MongoDBCollection-method-dropIndex-param.yaml
View file @
b33e5a5a
docs/includes/apiargs-MongoDBCollection-method-dropIndexes-option.yaml
View file @
b33e5a5a
docs/includes/apiargs-MongoDBCollection-method-dropIndexes-param.yaml
View file @
b33e5a5a
docs/includes/apiargs-MongoDBCollection-method-find-option.yaml
View file @
b33e5a5a
...
@@ -74,12 +74,11 @@ arg_name: option
...
@@ -74,12 +74,11 @@ arg_name: option
name
:
cursorType
name
:
cursorType
type
:
integer
type
:
integer
description
:
|
description
:
|
Indicates the type of cursor to use. The cursor types are
Indicates the type of cursor to use. ``cursorType`` supports the following
``MongoDB\Operation\Find`` class constants.
values:
Must be either
- ``MongoDB\Operation\Find::NON_TAILABLE`` (*default*)
``NON_TAILABLE``, ``TAILABLE``, or ``TAILABLE_AWAIT``. The default is
- ``MongoDB\Operation\Find::TAILABLE``
``NON_TAILABLE``.
interface
:
phpmethod
interface
:
phpmethod
operation
:
MongoDB\\Collection::find
operation
:
MongoDB\\Collection::find
optional
:
true
optional
:
true
...
...
docs/includes/apiargs-MongoDBCollection-method-findOne-option.yaml
View file @
b33e5a5a
docs/includes/apiargs-MongoDBCollection-method-findOneAndDelete-option.yaml
View file @
b33e5a5a
docs/includes/apiargs-MongoDBCollection-method-findOneAndReplace-option.yaml
View file @
b33e5a5a
...
@@ -22,10 +22,18 @@ source:
...
@@ -22,10 +22,18 @@ source:
operation
:
MongoDB\\Collection::findOneAndReplace
operation
:
MongoDB\\Collection::findOneAndReplace
position
:
4
position
:
4
---
---
source
:
arg_name
:
option
file
:
apiargs-MongoDBCollection-method-findOneAndUpdate-option.yaml
name
:
returnDocument
ref
:
returnDocument
type
:
integer
operation
:
MongoDB\\Collection::findOneAndReplace
description
:
|
Specifies whether to return the document before the replacementi applied, or
after. ``returnDocument`` supports the following values:
- ``MongoDB\Operation\FindOneAndReplace::RETURN_DOCUMENT_BEFORE`` (*default*)
- ``MongoDB\Operation\FindOneAndReplace::RETURN_DOCUMENT_AFTER``
interface
:
phpmethod
operation
:
MongoDB\Collection::findOneAndUpdate
optional
:
true
position
:
5
position
:
5
---
---
source
:
source
:
...
...
docs/includes/apiargs-MongoDBCollection-method-findOneAndUpdate-option.yaml
View file @
b33e5a5a
...
@@ -26,16 +26,14 @@ arg_name: option
...
@@ -26,16 +26,14 @@ arg_name: option
name
:
returnDocument
name
:
returnDocument
type
:
integer
type
:
integer
description
:
|
description
:
|
Specifies whether to return the document before the
{{event}}
, or
Specifies whether to return the document before the
update is applied
, or
after. ``returnDocument`` supports the following values:
after. ``returnDocument`` supports the following values:
- ``MongoDB\Operation\FindOneAndReplace::RETURN_DOCUMENT_BEFORE`` (*default*)
- ``MongoDB\Operation\FindOneAndUpdate::RETURN_DOCUMENT_BEFORE`` (*default*)
- ``MongoDB\Operation\FindOneAndReplace::RETURN_DOCUMENT_AFTER``
- ``MongoDB\Operation\FindOneAndUpdate::RETURN_DOCUMENT_AFTER``
optional
:
true
replacement
:
event
:
"
update
is
applied"
interface
:
phpmethod
interface
:
phpmethod
operation
:
MongoDB\Collection::findOneAndUpdate
operation
:
MongoDB\Collection::findOneAndUpdate
optional
:
true
position
:
5
position
:
5
---
---
source
:
source
:
...
...
docs/includes/apiargs-MongoDBCollection-method-insertMany-option.yaml
View file @
b33e5a5a
docs/includes/apiargs-MongoDBCollection-method-insertMany-param.yaml
View file @
b33e5a5a
docs/includes/apiargs-MongoDBCollection-method-insertOne-option.yaml
View file @
b33e5a5a
docs/includes/apiargs-MongoDBCollection-method-insertOne-param.yaml
View file @
b33e5a5a
docs/includes/apiargs-MongoDBCollection-method-replaceOne-option.yaml
View file @
b33e5a5a
docs/includes/apiargs-MongoDBCollection-method-updateMany-option.yaml
View file @
b33e5a5a
docs/includes/apiargs-MongoDBCollection-method-updateOne-option.yaml
View file @
b33e5a5a
docs/includes/apiargs-MongoDBCollection-method-withOptions-option.yaml
View file @
b33e5a5a
docs/includes/apiargs-common-option.yaml
View file @
b33e5a5a
docs/includes/apiargs-common-param.yaml
View file @
b33e5a5a
...
@@ -15,7 +15,7 @@ type: string
...
@@ -15,7 +15,7 @@ type: string
description
:
|
description
:
|
The name of the database{{action}}.
The name of the database{{action}}.
interface
:
phpmethod
interface
:
phpmethod
operation
:
selectCollection
operation
:
~
optional
:
false
optional
:
false
replacement
:
replacement
:
action
:
"
"
action
:
"
"
...
@@ -27,7 +27,7 @@ type: string
...
@@ -27,7 +27,7 @@ type: string
description
:
|
description
:
|
The name of the collection{{action}}.
The name of the collection{{action}}.
interface
:
phpmethod
interface
:
phpmethod
operation
:
selectCollection
operation
:
~
optional
:
false
optional
:
false
replacement
:
replacement
:
action
:
"
"
action
:
"
"
...
@@ -39,7 +39,7 @@ type: array
...
@@ -39,7 +39,7 @@ type: array
description
:
|
description
:
|
An array specifying the desired options.
An array specifying the desired options.
interface
:
phpmethod
interface
:
phpmethod
operation
:
selectCollection
operation
:
~
optional
:
true
optional
:
true
position
:
3
position
:
3
---
---
...
@@ -49,7 +49,7 @@ type: array|object
...
@@ -49,7 +49,7 @@ type: array|object
description
:
|
description
:
|
The filter criteria that specifies the documents to {{verb}}.
The filter criteria that specifies the documents to {{verb}}.
interface
:
phpmethod
interface
:
phpmethod
operation
:
count
operation
:
~
optional
:
false
optional
:
false
position
:
4
position
:
4
replacement
:
replacement
:
...
...
docs/includes/example-insertOne.rst
deleted
100644 → 0
View file @
b12430a8
.. code-block:: php
<?php
$database = new MongoDB\Client;
$collection = $database->selectCollection('users','restaurants');
$newUser = $collection->insertOne(
[
'username' => 'admin',
'email' => 'admin@example.com',
'name' => 'Anna Bennett'
],
);
echo "<pre>";
var_dump($newUser);
The output would resemble:
.. code-block:: none
object(MongoDB\InsertOneResult)#13 (3) {
["writeResult":"MongoDB\InsertOneResult":private]=>
object(MongoDB\Driver\WriteResult)#12 (9) {
["nInserted"]=>
int(1)
["nMatched"]=>
int(0)
["nModified"]=>
int(0)
["nRemoved"]=>
int(0)
["nUpserted"]=>
int(0)
["upsertedIds"]=>
array(0) {
}
["writeErrors"]=>
array(0) {
}
["writeConcernError"]=>
NULL
["writeConcern"]=>
array(4) {
["w"]=>
NULL
["wmajority"]=>
bool(false)
["wtimeout"]=>
int(0)
["journal"]=>
NULL
}
}
["insertedId":"MongoDB\InsertOneResult":private]=>
object(MongoDB\BSON\ObjectID)#11 (1) {
["oid"]=>
string(24) "577282631f417d1823121691"
}
["isAcknowledged":"MongoDB\InsertOneResult":private]=>
bool(true)
}
\ No newline at end of file
docs/includes/extracts-bson-deserialization-base.yaml
View file @
b33e5a5a
...
@@ -2,9 +2,8 @@ ref: _bson-deserialization
...
@@ -2,9 +2,8 @@ ref: _bson-deserialization
content
:
|
content
:
|
.. note::
.. note::
{{method}} does not
{{method}} does not yet support a ``typeMap`` option for BSON
yet support a ``typeMap`` option for BSON deserialization of the
deserialization of the returned document.
returned document.
Classes implementing
Classes implementing
:php:`MongoDB\\BSON\\Persistable <class.mongodb-bson-persistable>`
:php:`MongoDB\\BSON\\Persistable <class.mongodb-bson-persistable>`
...
...
docs/includes/extracts-bson-deserialization.yaml
View file @
b33e5a5a
...
@@ -3,19 +3,19 @@ source:
...
@@ -3,19 +3,19 @@ source:
file
:
extracts-bson-deserialization-base.yaml
file
:
extracts-bson-deserialization-base.yaml
ref
:
_bson-deserialization
ref
:
_bson-deserialization
replacement
:
replacement
:
method
:
"
:phpmethod:`MongoDB
\\
Collection::findOneAndDelete`"
method
:
"
:phpmethod:`MongoDB
\\
Collection::findOneAndDelete
()
`"
---
---
ref
:
bson-deserialization-findOneAndReplace
ref
:
bson-deserialization-findOneAndReplace
source
:
source
:
file
:
extracts-bson-deserialization-base.yaml
file
:
extracts-bson-deserialization-base.yaml
ref
:
_bson-deserialization
ref
:
_bson-deserialization
replacement
:
replacement
:
method
:
"
:phpmethod:`MongoDB
\\
Collection::findOneAndReplace`"
method
:
"
:phpmethod:`MongoDB
\\
Collection::findOneAndReplace
()
`"
---
---
ref
:
bson-deserialization-findOneAndUpdate
ref
:
bson-deserialization-findOneAndUpdate
source
:
source
:
file
:
extracts-bson-deserialization-base.yaml
file
:
extracts-bson-deserialization-base.yaml
ref
:
_bson-deserialization
ref
:
_bson-deserialization
replacement
:
replacement
:
method
:
"
:phpmethod:`MongoDB
\\
Collection::findOneAndUpdate`"
method
:
"
:phpmethod:`MongoDB
\\
Collection::findOneAndUpdate
()
`"
...
...
docs/reference/method/MongoDBCollection-aggregate.txt
View file @
b33e5a5a
...
@@ -13,7 +13,7 @@ MongoDB\\Collection::aggregate()
...
@@ -13,7 +13,7 @@ MongoDB\\Collection::aggregate()
Definition
Definition
----------
----------
.. phpmethod:: MongoDB\\Collection::aggregate(
$pipeline, $options
)
.. phpmethod:: MongoDB\\Collection::aggregate()
Executes an :manual:`aggregation framework pipeline
Executes an :manual:`aggregation framework pipeline
</core/aggregation-pipeline/>` operation on the collection.
</core/aggregation-pipeline/>` operation on the collection.
...
@@ -22,45 +22,46 @@ Definition
...
@@ -22,45 +22,46 @@ Definition
function aggregate(array $pipeline, array $options = []): Traversable
function aggregate(array $pipeline, array $options = []): Traversable
:phpmethod:`MongoDB\\Collection::aggregate` has the following
:phpmethod:`MongoDB\\Collection::aggregate()` has the following parameters:
parameters:
.. include:: /includes/apiargs/MongoDBCollection-method-aggregate-param.rst
.. include:: /includes/apiargs/MongoDBCollection-method-aggregate-param.rst
:phpmethod:`MongoDB\\Collection::aggregate` supports the following
The ``$options`` parameter supports the following options:
options:
.. include:: /includes/apiargs/MongoDBCollection-method-aggregate-option.rst
.. include:: /includes/apiargs/MongoDBCollection-method-aggregate-option.rst
.. _php-agg-method-output
:
:returns
:
Output
A :php:`MongoDB\\Driver\\Cursor <class.mongodb-driver-cursor>` or
------
:php:`ArrayIterator <arrayiterator>` object. In both cases, the return
value will be :php:`Traversable <traversable>`.
:phpmethod:`MongoDB\\Collection::aggregate`'s return value depends on
.. _php-agg-method-behavior:
the MongoDB server version and whether the ``useCursor`` option is
specified. If ``useCursor`` is true,
Behavior
:phpmethod:`MongoDB\\Collection::aggregate` returns a
--------
``MongoDB\Driver\Cursor`` object. If ``useCursor`` is false,
:phpmethod:`MongoDB\\Collection::aggregate` returns an
:phpmethod:`MongoDB\\Collection::aggregate()`'s return value depends on the
``ArrayIterator`` that wraps the ``result`` array from the command
MongoDB server version and whether the ``useCursor`` option is specified. If
response document.
``useCursor`` is ``true``, a :php:`MongoDB\\Driver\\Cursor
<class.mongodb-driver-cursor>` object is returned. If ``useCursor`` is
``false``, an :php:`ArrayIterator <arrayiterator>` is returned that wraps the
``result`` array from the command response document. In both cases, the return
value will be :php:`Traversable <traversable>`.
.. note::
.. note::
BSON deserialization of inline aggregation results (i.e. not using a
BSON deserialization of inline aggregation results (i.e. not using a command
command cursor) does not yet support a ``typeMap`` option. Classes
cursor) does not yet support a ``typeMap`` option. Classes implementing
implementing :php:`MongoDB\\BSON\\Persistable
:php:`MongoDB\\BSON\\Persistable <mongodb-bson-persistable>` will still be
<mongodb-bson-persistable>` will still be deserialized according to
deserialized according to the
the :php:`Persistence <mongodb.persistence.deserialization>`
:php:`Persistence <mongodb.persistence.deserialization>` specification.
specification.
.. todo: add examples
.. todo: add examples
.. seealso::
.. seealso::
- :manual:`aggregate command reference
- :manual:`aggregate </reference/command/aggregate>` command reference in the
</reference/command/aggregate>` in the MongoDB manual and
MongoDB manual
- :manual:`Aggregation Pipeline </core/aggregation-pipeline>`
- :manual:`Aggregation Pipeline </core/aggregation-pipeline>`
documentation in the MongoDB Manual
.
documentation in the MongoDB Manual
docs/reference/method/MongoDBCollection-bulkWrite.txt
View file @
b33e5a5a
...
@@ -13,7 +13,7 @@ MongoDB\\Collection::bulkWrite()
...
@@ -13,7 +13,7 @@ MongoDB\\Collection::bulkWrite()
Definition
Definition
----------
----------
.. phpmethod:: MongoDB\\Collection::bulkWrite(
$operations, $options
)
.. phpmethod:: MongoDB\\Collection::bulkWrite()
Executes multiple write operations.
Executes multiple write operations.
...
@@ -21,24 +21,29 @@ Definition
...
@@ -21,24 +21,29 @@ Definition
function bulkWrite(array $operations, array $options = []): MongoDB\BulkWriteResult
function bulkWrite(array $operations, array $options = []): MongoDB\BulkWriteResult
:phpmethod:`MongoDB\\Collection::bulkWrite` has the following
:phpmethod:`MongoDB\\Collection::bulkWrite()` has the following parameters:
parameters:
.. include:: /includes/apiargs/MongoDBCollection-method-bulkWrite-param.rst
.. include:: /includes/apiargs/MongoDBCollection-method-bulkWrite-param.rst
:phpmethod:`MongoDB\\Collection::bulkWrite` supports the following
The ``$options`` parameter supports the following options:
options:
.. include:: /includes/apiargs/MongoDBCollection-method-bulkWrite-option.rst
.. include:: /includes/apiargs/MongoDBCollection-method-bulkWrite-option.rst
:returns:
A :phpclass:`MongoDB\\BulkWriteResult` object, which encapsulates a
:php:`MongoDB\\Driver\\WriteResult <class.mongodb-driver-writeresult>`
object.
.. todo: add output and examples
.. todo: add output and examples
.. seealso::
.. seealso::
- :phpmethod:`deleteMany <MongoDB\\Collection::deleteMany>`
- :phpmethod:`MongoDB\\Collection::deleteMany()`
- :phpmethod:`deleteOne <MongoDB\\Collection::deleteOne>`
- :phpmethod:`MongoDB\\Collection::deleteOne()`
- :phpmethod:`insertOne <MongoDB\\Collection::insertOne>`
- :phpmethod:`MongoDB\\Collection::insertMany()`
- :phpmethod:`replaceOne <MongoDB\\Collection::replaceOne>`
- :phpmethod:`MongoDB\\Collection::insertOne()`
- :phpmethod:`updateMany <MongoDB\\Collection::updateMany>`
- :phpmethod:`MongoDB\\Collection::replaceOne()`
- :phpmethod:`updateOne <MongoDB\\Collection::updateOne>`
- :phpmethod:`MongoDB\\Collection::updateMany()`
- :phpmethod:`MongoDB\\Collection::updateOne()`
- :doc:`/tutorial/crud`
- :doc:`/tutorial/crud`
docs/reference/method/MongoDBCollection-count.txt
View file @
b33e5a5a
...
@@ -13,27 +13,29 @@ MongoDB\\Collection::count()
...
@@ -13,27 +13,29 @@ MongoDB\\Collection::count()
Definition
Definition
----------
----------
.. phpmethod:: MongoDB\\Collection::count(
$filter, $options
)
.. phpmethod:: MongoDB\\Collection::count()
Count
s the number of documents that match
filter criteria.
Count
the number of documents that match the
filter criteria.
.. code-block:: php
.. code-block:: php
function count($filter = [], array $options = []): integer
function count($filter = [], array $options = []): integer
:phpmethod:`MongoDB\\Collection::count` has the following
:phpmethod:`MongoDB\\Collection::count()` has the following parameters:
parameters:
.. include:: /includes/apiargs/MongoDBCollection-method-count-param.rst
.. include:: /includes/apiargs/MongoDBCollection-method-count-param.rst
:phpmethod:`MongoDB\\Collection::count` supports the following
The ``$options`` parameter supports the following options:
options:
.. include:: /includes/apiargs/MongoDBCollection-method-count-option.rst
.. include:: /includes/apiargs/MongoDBCollection-method-count-option.rst
:returns:
The number of documents matching the filter criteria.
.. todo: add output and examples
.. todo: add output and examples
.. seealso::
.. seealso::
- :manual:`count
command reference </reference/command/count>`
- :manual:`count
</reference/command/count>` command reference in the MongoDB
in the MongoDB manual.
manual
docs/reference/method/MongoDBCollection-createIndex.txt
View file @
b33e5a5a
...
@@ -13,7 +13,7 @@ MongoDBCollection::createIndex()
...
@@ -13,7 +13,7 @@ MongoDBCollection::createIndex()
Definition
Definition
----------
----------
.. phpmethod:: MongoDB\\Collection::createIndex(
$key, $options
)
.. phpmethod:: MongoDB\\Collection::createIndex()
Create an index for the collection.
Create an index for the collection.
...
@@ -21,23 +21,22 @@ Definition
...
@@ -21,23 +21,22 @@ Definition
function createIndex($key, array $options = []): string
function createIndex($key, array $options = []): string
``createIndex()`` accept
s the following parameters:
:phpmethod:`MongoDB\\Collection::createIndex()` ha
s the following parameters:
.. include:: /includes/apiargs/MongoDBCollection-method-createIndex-param.rst
.. include:: /includes/apiargs/MongoDBCollection-method-createIndex-param.rst
The ``$options`` parameter accepts all index options that your
The ``$options`` parameter accepts all index options that your
MongoDB
MongoDB
version supports. MongoDB 3.2 includes the following options:
version supports. MongoDB 3.2 includes the following options:
.. include:: /includes/apiargs/MongoDBCollection-method-createIndex-option.rst
.. include:: /includes/apiargs/MongoDBCollection-method-createIndex-option.rst
For a full list of the supported index creation options, refer to
For a full list of the supported index creation options, refer to
the
the :manual:`createIndexes </reference/command/createIndexes>`
:manual:`createIndexes </reference/command/createIndexes>` command reference
command reference
in the MongoDB manual.
in the MongoDB manual.
Output
:returns:
------
Returns t
he name of the created index as a string.
T
he name of the created index as a string.
Examples
Examples
--------
--------
...
@@ -45,63 +44,57 @@ Examples
...
@@ -45,63 +44,57 @@ Examples
Create a Compound Index
Create a Compound Index
~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~
The following
operation creates a :manual:`compound index
The following
example creates a :manual:`compound index </core/index-compound>`
</core/index-compound>` on the ``borough`` and ``cuisine`` fields
on the ``borough`` and ``cuisine`` fields in the ``restaurants`` collection in
in the ``restaurants`` collection
.
the ``example`` database
.
.. code-block:: php
.. code-block:: php
<?php
<?php
$
database = new MongoDB\Client
;
$
collection = (new MongoDB\Client)->selectCollection('example', 'restaurants')
;
$
collection = $database->selectCollection('example','restaurants'
);
$
indexName = $collection->createIndex(['borough' => 1, 'cuisine' => 1]
);
$keys = ['borough' => 1, 'cuisine' => 1]
;
var_dump($indexName)
;
$indexString = $collection->createIndex($keys, ['name' => 'compound']);
The output would then resemble::
var_dump($indexString);
string(19) "borough_1_cuisine_1"
The output would resemble the following:
.. code-block:: none
string(8) "compound"
Create a Partial Index
Create a Partial Index
~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~
The following
operation adds a :manual:`partial index
The following
example adds a :manual:`partial index </core/index-parital>` on
</core/index-parital>` on the ``borough`` field in the ``restaurants
``
the ``borough`` field in the ``restaurants`` collection in the ``example
``
collection in the ``example`` database. The partial index indexes only
database. The partial index indexes only documents where the ``borough`` field
fields where the ``borough`` field
exists.
exists.
.. code-block:: php
.. code-block:: php
<?php
<?php
$database = new MongoDB\Client;
$collection = (new MongoDB\Client)->selectCollection('example, 'restaurants');
$collection = $database->selectCollection('example','restaurants');
$index
String
= $collection->createIndex(
$index
Name
= $collection->createIndex(
['borough' => 1],
['borough' => 1],
['partialFilterExpression'=>
[
['borough'=>
'partialFilterExpression' => [
['$exists'=>true]
'borough' => ['$exists' => true],
]]);
],
]
);
var_dump($index
String
);
var_dump($index
Name
);
The output would resemble::
The output would
then
resemble::
string(9) "borough_1"
string(9) "borough_1"
.. seealso::
.. seealso::
- :phpmethod:`MongoDB\\Collection::createIndexes`
- :phpmethod:`MongoDB\\Collection::createIndexes
()
`
- :doc:`/tutorial/indexes`
- :doc:`/tutorial/indexes`
- :manual:`createIndexes </reference/command/createIndexes>`
- :manual:`createIndexes </reference/command/createIndexes>`
command
command
reference in the MongoDB manual
reference in the MongoDB manual
- :manual:`Index
documentation </indexes>`
- :manual:`Index
</indexes>` documentation in the MongoDB Manual
docs/reference/method/MongoDBCollection-createIndexes.txt
View file @
b33e5a5a
...
@@ -21,66 +21,57 @@ Definition
...
@@ -21,66 +21,57 @@ Definition
function createIndexes(array $indexes): string[]
function createIndexes(array $indexes): string[]
``createIndex()`` has one parameter
: ``$indexes``, which is an array
``createIndex()`` has one parameter
, ``$indexes``, which is an array. Each
or object.
element in ``$indexes`` must itself be an array that specifies an index. The
Each element in the ``$indexes`` array|object must have a
specification array requires a ``key`` field, which corresponds to the
"``key`` document" that specifies the fields to index and the
``$key`` parameter of :phpmethod:`MongoDB\\Collection::createIndex()`, and
array direction or type. You can then specify index options as
may have other fields that correspond to options of
additional key-value pairs in that element
.
:phpmethod:`MongoDB\\Collection::createIndex()`
.
For example, the following ``$indexes`` parameter creates an ascending
For example, the following ``$indexes`` parameter creates two indexes. The
unique index on the ``username`` field:
first is an ascending unique index on the ``username`` field and the second
is a 2dsphere index on the ``loc`` field with a custom name::
.. code-block:: none
[
[ 'key' => [ 'username' => 1 ], 'unique' => true ],
[ 'key' => ['username => 1 '], 'unique' => true ],
[ 'key' => [ 'loc' => '2dsphere' ], 'name' => 'geo_index' ],
]
The following ``$indexes`` parameter creates a 2dsphere index on the ``loc`` field and
specifies a custom index name:
.. code-block:: none
[ 'key' => [ 'loc' => '2dsphere'], 'name' => 'geo_index' ],
You can specify any index options that your MongoDB version
You can specify any index options that your MongoDB version
supports. MongoDB 3.2 includes the following options:
supports. MongoDB 3.2 includes the following options:
.. include:: /includes/apiargs/MongoDBCollection-method-createIndex-option.rst
.. include:: /includes/apiargs/MongoDBCollection-method-createIndex-option.rst
For a full list of the supported index creation options, refer to
For a full list of the supported index creation options, refer to
the
the :manual:`createIndexes </reference/command/createIndexes>`
:manual:`createIndexes </reference/command/createIndexes>` command reference
command reference
in the MongoDB manual.
in the MongoDB manual.
Output
:returns:
------
Returns the name
of the created indexes as an array of strings.
The names
of the created indexes as an array of strings.
Example
Example
-------
-------
The following creates two indexes on the ``restaurants`` collection in
The following
example
creates two indexes on the ``restaurants`` collection in
the ``example`` database. One index is a compound index on the
the ``example`` database. One index is a compound index on the
``borough`` and
``
borough`` and ``cuisine`` fields and the other is 2dsphere index
``
cuisine`` fields and the other is 2dsphere index on the ``loc`` field with a
on the ``location`` field with a
custom name.
custom name.
.. code-block:: php
.. code-block:: php
<?php
<?php
$database = new MongoDB\Client;
$collection = (new MongoDB\Client)->selectCollection('example', 'restaurants');
$collection = $database->selectCollection('example','restaurants');
$index = $collection->createIndexes(
$indexNames = $collection->createIndexes([
[
[ 'key' => [ 'borough' => 1, 'cuisine' => 1] ],
[ 'key' => [ 'borough' => 1, 'cuisine' => 1] ],
[ 'key' => [ 'location' => '2dsphere'], 'name' => 'geo_index'
],
[ 'key' => [ 'loc' => '2dsphere'], 'name' => 'geo_index'
],
]);
]);
var_dump($index);
var_dump($index
Names
);
The output would
resemble the following
::
The output would
then resemble
::
array(2) {
array(2) {
[0]=>
[0]=>
...
@@ -91,8 +82,8 @@ The output would resemble the following::
...
@@ -91,8 +82,8 @@ The output would resemble the following::
.. seealso::
.. seealso::
- :phpmethod:`MongoDB\\Collection::createIndex`
- :phpmethod:`MongoDB\\Collection::createIndex
()
`
- :doc:`/tutorial/indexes`
- :doc:`/tutorial/indexes`
- :manual:`createIndexes </reference/command/createIndexes>`
- :manual:`createIndexes </reference/command/createIndexes>`
command
command
reference in the MongoDB manual
reference in the MongoDB manual
- :manual:`Index
documentation </indexes>`
- :manual:`Index
</indexes>` documentation in the MongoDB Manual
docs/reference/method/MongoDBCollection-deleteMany.txt
View file @
b33e5a5a
...
@@ -13,7 +13,7 @@ MongoDB\\Collection::deleteMany()
...
@@ -13,7 +13,7 @@ MongoDB\\Collection::deleteMany()
Definition
Definition
----------
----------
.. phpmethod:: MongoDB\\Collection::deleteMany(
$filter, $options
)
.. phpmethod:: MongoDB\\Collection::deleteMany()
Deletes all documents that match the filter criteria.
Deletes all documents that match the filter criteria.
...
@@ -21,26 +21,25 @@ Definition
...
@@ -21,26 +21,25 @@ Definition
function deleteMany($filter, array $options = []): MongoDB\DeleteResult
function deleteMany($filter, array $options = []): MongoDB\DeleteResult
:phpmethod:`MongoDB\\Collection::deleteMany` has the following
:phpmethod:`MongoDB\\Collection::deleteMany()` has the following parameters:
parameters:
.. include:: /includes/apiargs/MongoDBCollection-method-deleteMany-param.rst
.. include:: /includes/apiargs/MongoDBCollection-method-deleteMany-param.rst
:phpmethod:`MongoDB\\Collection::deleteMany` supports the following
The ``$options`` parameter supports the following options:
options:
.. include:: /includes/apiargs/MongoDBCollection-method-deleteMany-option.rst
.. include:: /includes/apiargs/MongoDBCollection-method-deleteMany-option.rst
Output
:returns:
------
Returns a ``MongoDB\DeleteResult`` object.
A :phpclass:`MongoDB\\DeleteResult` object, which encapsulates a
:php:`MongoDB\\Driver\\WriteResult <class.mongodb-driver-writeresult>`
object.
Example
Example
-------
-------
The following
operation deletes all of the documents in the ``users``
The following
example deletes all of the documents in the ``users`` collection
collection that have ``ny
`` as the value for the ``state`` field:
that have ``"ny"
`` as the value for the ``state`` field:
.. code-block:: php
.. code-block:: php
...
@@ -59,11 +58,10 @@ The output would then resemble::
...
@@ -59,11 +58,10 @@ The output would then resemble::
Deleted 2 document(s)
Deleted 2 document(s)
.. seealso::
.. seealso::
- :phpmethod:`MongoDB\\Collection::
bulkWrite
`
- :phpmethod:`MongoDB\\Collection::
deleteOne()
`
- :phpmethod:`MongoDB\\Collection::
deleteOne
`
- :phpmethod:`MongoDB\\Collection::
bulkWrite()
`
- :doc:`/tutorial/crud`
- :doc:`/tutorial/crud`
- :manual:`delete command reference </reference/command/delete`
- :manual:`delete </reference/command/delete` command reference in the
in the MongoDB manual
MongoDB manual
\ No newline at end of file
docs/reference/method/MongoDBCollection-deleteOne.txt
View file @
b33e5a5a
...
@@ -13,37 +13,35 @@ MongoDB\\Collection::deleteOne()
...
@@ -13,37 +13,35 @@ MongoDB\\Collection::deleteOne()
Definition
Definition
----------
----------
.. phpmethod:: MongoDB\\Collection::deleteOne(
$filter, $options
)
.. phpmethod:: MongoDB\\Collection::deleteOne()
Deletes at most one document that matches the filter criteria. If
Deletes at most one document that matches the filter criteria. If multiple
multiple documents match the filter criteria,
documents match the filter criteria, only the :term:`first <natural order>`
:phpmethod:`MongoDB\\Collection::deleteOne` deletes the :term:`first
matching document will be deleted.
<natural order>` matching document.
.. code-block:: php
.. code-block:: php
function deleteOne($filter, array $options = []): MongoDB\DeleteResult
function deleteOne($filter, array $options = []): MongoDB\DeleteResult
:phpmethod:`MongoDB\\Collection::deleteMany` has the following
:phpmethod:`MongoDB\\Collection::deleteOne()` has the following parameters:
parameters:
.. include:: /includes/apiargs/MongoDBCollection-method-deleteOne-param.rst
.. include:: /includes/apiargs/MongoDBCollection-method-deleteOne-param.rst
:phpmethod:`MongoDB\\Collection::deleteMany` supports the following
The ``$options`` parameter supports the following options:
options:
.. include:: /includes/apiargs/MongoDBCollection-method-deleteOne-option.rst
.. include:: /includes/apiargs/MongoDBCollection-method-deleteOne-option.rst
Output
:returns:
------
Returns a ``MongoDB\DeleteResult`` object.
A :phpclass:`MongoDB\\DeleteResult` object, which encapsulates a
:php:`MongoDB\\Driver\\WriteResult <class.mongodb-driver-writeresult>`
object.
Example
Example
-------
-------
The following
operation deletes the first documents in the ``users``
The following
example deletes one document in the ``users`` collection that has
collection that has ``ny
`` as the value for the ``state`` field:
has ``"ny"
`` as the value for the ``state`` field:
.. code-block:: php
.. code-block:: php
...
@@ -64,8 +62,8 @@ The output would then resemble::
...
@@ -64,8 +62,8 @@ The output would then resemble::
.. seealso::
.. seealso::
- :phpmethod:`MongoDB\\Collection::
bulkWrite
`
- :phpmethod:`MongoDB\\Collection::
deleteMany()
`
- :phpmethod:`MongoDB\\Collection::
deleteMany
`
- :phpmethod:`MongoDB\\Collection::
bulkWrite()
`
- :doc:`/tutorial/crud`
- :doc:`/tutorial/crud`
- :manual:`delete command reference </reference/command/delete`
- :manual:`delete command reference </reference/command/delete`
in the MongoDB manual
in the MongoDB manual
docs/reference/method/MongoDBCollection-distinct.txt
View file @
b33e5a5a
...
@@ -21,7 +21,7 @@ Definition
...
@@ -21,7 +21,7 @@ Definition
function distinct($fieldName, $filter = [], array $options = []): mixed[]
function distinct($fieldName, $filter = [], array $options = []): mixed[]
``distinct`
` has the following parameters:
:phpmethod:`MongoDB\\Collection::distinct()
` has the following parameters:
.. include:: /includes/apiargs/MongoDBCollection-method-distinct-param.rst
.. include:: /includes/apiargs/MongoDBCollection-method-distinct-param.rst
...
@@ -29,10 +29,9 @@ Definition
...
@@ -29,10 +29,9 @@ Definition
.. include:: /includes/apiargs/MongoDBCollection-method-distinct-option.rst
.. include:: /includes/apiargs/MongoDBCollection-method-distinct-option.rst
Output
:returns:
------
Returns a
n array of the distinct values.
A
n array of the distinct values.
Examples
Examples
--------
--------
...
@@ -40,23 +39,20 @@ Examples
...
@@ -40,23 +39,20 @@ Examples
Return Distinct Values for a Field
Return Distinct Values for a Field
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The following example identifies the distinct values for the
The following example identifies the distinct values for the ``borough`` field
``borough`` field in the ``restaurants`` collection in the
in the ``restaurants`` collection in the ``example`` database.
``example`` database.
.. code-block:: php
.. code-block:: php
<?php
<?php
$database = new MongoDB\Client;
$collection = (new MongoDB\Client)->example->restaurants;
$collection = $database->selectCollection('example','restaurants');
$distinct = $collection->distinct('borough');
$distinct = $collection->distinct('borough');
var_dump($distinct);
var_dump($distinct);
The output would resemble::
The output would
then
resemble::
array(6) {
array(6) {
[0]=>
[0]=>
...
@@ -73,24 +69,20 @@ The output would resemble::
...
@@ -73,24 +69,20 @@ The output would resemble::
string(13) "Staten Island"
string(13) "Staten Island"
}
}
Return Distinct Values Using a Filter
Return Distinct Values Using a Filter
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
The following example identifies the distinct values for the
The following example identifies the distinct values for the
``cuisine`` field
``cuisine`` field in the ``restaurants`` collection in the ``example``
in the ``restaurants`` collection in the ``example`` database for documents
database for documents
where the ``borough`` is ``Queens``:
where the ``borough`` is ``Queens``:
.. code-block:: php
.. code-block:: php
<?php
<?php
$database = new MongoDB\Client;
$collection = (new MongoDB\Client)->example->restaurants;
$collection = $database->selectCollection('example','restaurants');
$distinct = $collection->distinct('cuisine', ['borough'=>'Queens']);
$distinct = $collection->distinct('cuisine', ['borough' => 'Queens']);
var_dump($distinct);
var_dump($distinct);
...
@@ -249,8 +241,7 @@ The output would then resemble::
...
@@ -249,8 +241,7 @@ The output would then resemble::
string(29) "Vietnamese/Cambodian/Malaysia"
string(29) "Vietnamese/Cambodian/Malaysia"
}
}
.. seealso::
.. seealso::
- :manual:`distinct </reference/command/distinct>` command
- :manual:`distinct </reference/command/distinct>` command
reference in the
reference in the MongoDB manual.
MongoDB manual
docs/reference/method/MongoDBCollection-drop.txt
View file @
b33e5a5a
...
@@ -13,48 +13,45 @@ MongoDB\\Collection::drop()
...
@@ -13,48 +13,45 @@ MongoDB\\Collection::drop()
Definition
Definition
----------
----------
.. phpmethod:: MongoDB\\Collection::drop
.. phpmethod:: MongoDB\\Collection::drop
()
Drop
s
the collection.
Drop the collection.
.. code-block:: php
.. code-block:: php
function drop(array $options = []): array|object
function drop(array $options = []): array|object
``drop()`` supports the following parameter
:
:phpmethod:`MongoDB\\Collection::drop()` has the following parameters
:
.. include:: /includes/apiargs/MongoDBCollection-method-drop-param.rst
.. include:: /includes/apiargs/MongoDBCollection-method-drop-param.rst
The ``$options`` parameter supports the following option:
The ``$options`` parameter supports the following option
s
:
.. include:: /includes/apiargs/MongoDBCollection-method-drop-option.rst
.. include:: /includes/apiargs/MongoDBCollection-method-drop-option.rst
Output
:returns:
------
Returns the command result document as an array or object, depending
An array or object with the result document of the :manual:`drop
on the ``typeMap`` specification.
</reference/command/drop>` command. The return type will depend on the
``typeMap`` option.
Example
Example
-------
-------
The following operation drops the ``restaurants`` collection in the
The following operation drops the ``restaurants`` collection in the
``example``
``example``
database:
database:
.. code-block:: php
.. code-block:: php
<?php
<?php
$
database = new MongoDB\Client
;
$
collection = (new MongoDB\Client)->example->restaurants
;
$
collection = $database->selectCollection('example','restaurants'
);
$
result = $collection->drop(
);
$output = $collection->drop(
);
var_dump($result
);
The output would then resemble::
var_dump($output);
The output would resemble::
object(MongoDB\Model\BSONDocument)#9 (1) {
object(MongoDB\Model\BSONDocument)#9 (1) {
["storage":"ArrayObject":private]=>
["storage":"ArrayObject":private]=>
...
@@ -70,7 +67,6 @@ The output would resemble::
...
@@ -70,7 +67,6 @@ The output would resemble::
.. seealso::
.. seealso::
- :phpmethod:`MongoDB\\Database::dropCollection`
- :phpmethod:`MongoDB\\Database::dropCollection()`
- :manual:`drop </reference/command/drop>` command reference in
- :manual:`drop </reference/command/drop>` command reference in the MongoDB
the MongoDB manual.
manual
docs/reference/method/MongoDBCollection-dropIndex.txt
View file @
b33e5a5a
...
@@ -13,49 +13,45 @@ MongoDB\\Collection::dropIndex()
...
@@ -13,49 +13,45 @@ MongoDB\\Collection::dropIndex()
Definition
Definition
----------
----------
.. phpmethod:: MongoDB\\Collection::dropIndex(
$indexName, $options
)
.. phpmethod:: MongoDB\\Collection::dropIndex()
Drop
s
an index from the collection.
Drop an index from the collection.
.. code-block:: php
.. code-block:: php
function dropIndex($indexName, array $options = []): array|object
function dropIndex($indexName, array $options = []): array|object
``dropIndex()`` support
s the following parameters:
:phpmethod:`MongoDB\\Collection::dropIndex()` ha
s the following parameters:
.. include:: /includes/apiargs/MongoDBCollection-method-dropIndex-param.rst
.. include:: /includes/apiargs/MongoDBCollection-method-dropIndex-param.rst
The ``$options`` parameter supports the following option:
The ``$options`` parameter supports the following option
s
:
.. include:: /includes/apiargs/MongoDBCollection-method-dropIndex-option.rst
.. include:: /includes/apiargs/MongoDBCollection-method-dropIndex-option.rst
Output
:returns:
------
Returns the command result document as an array or object, depending
An array or object with the result document of the :manual:`dropIndexes
on the ``typeMap`` specification.
</reference/command/dropIndexes>` command. The return type will depend on
the ``typeMap`` option.
Example
Example
-------
-------
The following drops an indexes with name ``borough_1`` from the
The following drops an indexes with name ``borough_1`` from the
``restaurants``
``restaurants``
collection in the ``example`` database:
collection in the ``example`` database:
.. code-block:: php
.. code-block:: php
<?php
<?php
$
database = new MongoDB\Client
;
$
collection = (new MongoDB\Client)->example->restaurants
;
$
collection = $database->selectCollection('example','restaurants
');
$
result = $collection->dropIndex('borough_1
');
$index = $collection->dropIndex( "borough_1"
);
var_dump($result
);
The output would then resemble::
var_dump($index);
The output would resemble the following::
object(MongoDB\Model\BSONDocument)#9 (1) {
object(MongoDB\Model\BSONDocument)#9 (1) {
["storage":"ArrayObject":private]=>
["storage":"ArrayObject":private]=>
...
@@ -69,8 +65,8 @@ The output would resemble the following::
...
@@ -69,8 +65,8 @@ The output would resemble the following::
.. seealso::
.. seealso::
- :phpmethod:`MongoDB\\Collection::dropIndexes`
- :phpmethod:`MongoDB\\Collection::dropIndexes
()
`
- :doc:`/tutorial/indexes`
- :doc:`/tutorial/indexes`
- :manual:`dropIndexes </reference/command/dropIndexes>` command
- :manual:`dropIndexes </reference/command/dropIndexes>` command
reference
references in the MongoDB manual.
in the MongoDB manual
- :manual:`Index documentation </indexes>`
- :manual:`Index documentation </indexes>`
in the MongoDB manual
docs/reference/method/MongoDBCollection-dropIndexes.txt
View file @
b33e5a5a
...
@@ -13,48 +13,46 @@ MongoDB\\Collection::dropIndexes()
...
@@ -13,48 +13,46 @@ MongoDB\\Collection::dropIndexes()
Definition
Definition
----------
----------
.. phpmethod:: MongoDB\\Collection::dropIndexes(
$options
)
.. phpmethod:: MongoDB\\Collection::dropIndexes()
Drops **all indexes** in the collection.
Drop all indexes in the collection, except for the required index on the
``_id`` field.
.. code-block:: php
.. code-block:: php
function dropIndexes(array $options = []): array|object
function dropIndexes(array $options = []): array|object
``dropIndexes()`` support
s the following parameters:
:phpmethod:`MongoDB\\Collection::dropIndexes()` ha
s the following parameters:
.. include:: /includes/apiargs/MongoDBCollection-method-dropIndex-param.rst
.. include:: /includes/apiargs/MongoDBCollection-method-dropIndex-param.rst
The ``$options`` parameter supports the following option:
The ``$options`` parameter supports the following option
s
:
.. include:: /includes/apiargs/MongoDBCollection-method-dropIndex-option.rst
.. include:: /includes/apiargs/MongoDBCollection-method-dropIndex-option.rst
Output
:returns:
------
Returns the command result document as an array or object, depending
An array or object with the result document of the :manual:`dropIndexes
on the ``typeMap`` specification.
</reference/command/dropIndexes>` command. The return type will depend on
the ``typeMap`` option.
Example
Example
-------
-------
The following drops all indexes from the ``restaurants`` collection in
The following drops all indexes from the ``restaurants`` collection in
the
the
``example`` database:
``example`` database:
.. code-block:: php
.. code-block:: php
<?php
<?php
$
database = new MongoDB\Client
;
$
collection = (new MongoDB\Client)->example->restaurants
;
$
collection = $database->selectCollection('example','restaurants'
);
$
result = $collection->dropIndexes(
);
$response = $collection->dropIndexes(
);
var_dump($result
);
var_dump($response);
The output would then resemble::
The output would resemble the following::
object(MongoDB\Model\BSONDocument)#9 (1) {
object(MongoDB\Model\BSONDocument)#9 (1) {
["storage":"ArrayObject":private]=>
["storage":"ArrayObject":private]=>
...
@@ -70,8 +68,8 @@ The output would resemble the following::
...
@@ -70,8 +68,8 @@ The output would resemble the following::
.. seealso::
.. seealso::
- :phpmethod:`MongoDB\\Collection::dropIndex`
- :phpmethod:`MongoDB\\Collection::dropIndex
()
`
- :doc:`/tutorial/indexes`
- :doc:`/tutorial/indexes`
- :manual:`dropIndexes </reference/command/dropIndexes>` command
- :manual:`dropIndexes </reference/command/dropIndexes>` command
reference
references in the MongoDB manual.
in the MongoDB manual
- :manual:`Index documentation </indexes>`
- :manual:`Index documentation </indexes>`
in the MongoDB manual
docs/reference/method/MongoDBCollection-find.txt
View file @
b33e5a5a
...
@@ -10,11 +10,10 @@ MongoDB\\Collection::find()
...
@@ -10,11 +10,10 @@ MongoDB\\Collection::find()
:depth: 1
:depth: 1
:class: singlecol
:class: singlecol
Definition
Definition
----------
----------
.. phpmethod:: MongoDB\\Collection::find
.. phpmethod:: MongoDB\\Collection::find
()
Finds documents matching the query.
Finds documents matching the query.
...
@@ -22,7 +21,7 @@ Definition
...
@@ -22,7 +21,7 @@ Definition
function find($filter = [], array $options = []): MongoDB\Driver\Cursor
function find($filter = [], array $options = []): MongoDB\Driver\Cursor
``find()`` support
s the following parameters:
:phpmethod:`MongoDB\\Collection::find()` ha
s the following parameters:
.. include:: /includes/apiargs/MongoDBCollection-method-find-param.rst
.. include:: /includes/apiargs/MongoDBCollection-method-find-param.rst
...
@@ -30,43 +29,42 @@ Definition
...
@@ -30,43 +29,42 @@ Definition
.. include:: /includes/apiargs/MongoDBCollection-method-find-option.rst
.. include:: /includes/apiargs/MongoDBCollection-method-find-option.rst
:returns:
Output
A :php:`MongoDB\\Driver\\Cursor <class.mongodb-driver-cursor>` object.
------
Returns a ``MongoDB\Driver\Cursor`` object.
Examples
Examples
--------
--------
The following example finds restaurants based on the ``cuisine`` and
The following example finds restaurants based on the ``cuisine`` and
``borough``
``borough``
fields and uses a :manual:`projection
fields and uses a :manual:`projection
</tutorial/project-fields-from-query-results>` to limit the fields
</tutorial/project-fields-from-query-results>` to limit the fields
that are
that are
returned. It also limits the results to 5 documents.
returned. It also limits the results to 5 documents.
.. code-block:: php
.. code-block:: php
$database = new MongoDB\Client;
$collection = (new MongoDB\Client)->example->restaurants;
$collection = $database->selectCollection('example','restaurants');
$restaurants = $collection->find(
$cursor = $collection->find(
[ 'cuisine' => 'Italian', 'borough' => 'Manhattan' ],
[
[ 'limit' => 5,
'cuisine' => 'Italian',
'borough' => 'Manhattan',
],
[
'limit' => 5,
'projection' => [
'projection' => [
'name' => 1, 'borough' => 1, 'cuisine' => 1,
'name' => 1,
'borough' => 1,
'cuisine' => 1,
],
],
]
]
);
);
foreach ($cursor as $restaurant) {
foreach ($restaurants as $restaurant) {
var_dump($restaurant);
var_dump($restaurant);
};
};
The output would resemble:
The output would then resemble::
.. code-block:: none
object(MongoDB\Model\BSONDocument)#10 (1) {
object(MongoDB\Model\BSONDocument)#10 (1) {
["storage":"ArrayObject":private]=>
["storage":"ArrayObject":private]=>
...
@@ -151,6 +149,6 @@ The output would resemble:
...
@@ -151,6 +149,6 @@ The output would resemble:
.. seealso::
.. seealso::
- :phpmethod:`MongoDB\\Collection::findOne`
- :phpmethod:`MongoDB\\Collection::findOne
()
`
- :manual:`find </reference/command/find>` command reference
- :manual:`find </reference/command/find>` command reference
in the MongoDB
in the MongoDB
manual
manual
docs/reference/method/MongoDBCollection-findOne.txt
View file @
b33e5a5a
...
@@ -10,19 +10,18 @@ MongoDB\\Collection::findOne()
...
@@ -10,19 +10,18 @@ MongoDB\\Collection::findOne()
:depth: 1
:depth: 1
:class: singlecol
:class: singlecol
Definition
Definition
----------
----------
.. phpmethod:: MongoDB\\Collection::findOne
.. phpmethod:: MongoDB\\Collection::findOne
()
Finds a single document matching the query.
Finds a single document matching the query.
.. code-block:: php
.. code-block:: php
function findOne($filter = [], array $options = []): array|object
function findOne($filter = [], array $options = []): array|object
|null
``findOne()`` support
s the following parameters:
:phpmethod:`MongoDB\\Collection::findOne()` ha
s the following parameters:
.. include:: /includes/apiargs/MongoDBCollection-method-findOne-param.rst
.. include:: /includes/apiargs/MongoDBCollection-method-findOne-param.rst
...
@@ -30,56 +29,61 @@ Definition
...
@@ -30,56 +29,61 @@ Definition
.. include:: /includes/apiargs/MongoDBCollection-method-findOne-option.rst
.. include:: /includes/apiargs/MongoDBCollection-method-findOne-option.rst
:returns:
Output
An array or object for the :term:`first document <natural order>` document
------
that matched the query, or ``null`` if no document matched the query. The
return type will depend on the ``typeMap`` option.
Returns the :term:`first document <natural order>` that matches the
query or ``null`` if no document matches the query.
Examples
Examples
--------
--------
The following example finds a restaurant based on the ``cuisine`` and
The following example finds a restaurant based on the ``cuisine`` and
``borough`` fields and uses a :manual:`projection
``borough`` fields and uses a :manual:`projection
</tutorial/project-fields-from-query-results>` to limit the fields
</tutorial/project-fields-from-query-results>` to limit the fields
that are
that are
returned.
returned.
.. code-block:: php
.. code-block:: php
$database = new MongoDB\Client;
$collection = (new MongoDB\Client)->example->restaurants;
$collection = $database->selectCollection('example','restaurants');
$restaurants = $collection->findOne(
$restaurant = $collection->findOne(
[ 'cuisine' => 'Italian', 'borough' => 'Manhattan'],
[
[ 'limit' => 5,
'cuisine' => 'Italian',
'borough' => 'Manhattan',
],
[
'projection' => [
'projection' => [
'name' => 1, 'borough' => 1, 'cuisine' => 1,
'name' => 1,
'borough' => 1,
'cuisine' => 1,
],
],
]
]
);
);
foreach ($restaurants as $restaurant) {
var_dump($restaurant);
var_dump($restaurant);
};
The output would
resemble
:
The output would
then resemble:
:
.. code-block:: none
object(MongoDB\Model\BSONDocument)#10 (1) {
["storage":"ArrayObject":private]=>
object(MongoDB\BSON\ObjectID)#11 (1) {
array(4) {
["_id"]=>
object(MongoDB\BSON\ObjectID)#8 (1) {
["oid"]=>
["oid"]=>
string(24) "576023c6b02fa9281da3f983"
string(24) "576023c6b02fa9281da3f983"
}
}
["borough"]=>
string(9) "Manhattan"
string(9) "Manhattan"
["cuisine"]=>
string(7) "Italian"
string(7) "Italian"
["name"]=>
string(23) "Isle Of Capri Resturant"
string(23) "Isle Of Capri Resturant"
}
}
.. seealso::
.. seealso::
- :phpmethod:`MongoDB\\Collection::find
One
`
- :phpmethod:`MongoDB\\Collection::find
()
`
- :manual:`find </reference/command/find>` command reference
- :manual:`find </reference/command/find>` command reference
in the MongoDB
in the MongoDB
manual
manual
docs/reference/method/MongoDBCollection-findOneAndDelete.txt
View file @
b33e5a5a
...
@@ -10,19 +10,19 @@ MongoDB\\Collection::findOneAndDelete()
...
@@ -10,19 +10,19 @@ MongoDB\\Collection::findOneAndDelete()
:depth: 1
:depth: 1
:class: singlecol
:class: singlecol
Definition
Definition
----------
----------
.. phpmethod:: MongoDB\\Collection::findOneAndDelete
.. phpmethod:: MongoDB\\Collection::findOneAndDelete
()
Finds a single document and deletes it.
Finds a single document
matching the query
and deletes it.
.. code-block:: php
.. code-block:: php
function findOneAndDelete($filter = [], array $options = []): object|null
function findOneAndDelete($filter = [], array $options = []): object|null
``findOne()`` supports the following parameters:
:phpmethod:`MongoDB\\Collection::findOneAndDelete()` has the following
parameters:
.. include:: /includes/apiargs/MongoDBCollection-method-findOneAndDelete-param.rst
.. include:: /includes/apiargs/MongoDBCollection-method-findOneAndDelete-param.rst
...
@@ -32,39 +32,37 @@ Definition
...
@@ -32,39 +32,37 @@ Definition
.. include:: /includes/extracts/bson-deserialization-findOneAndDelete.rst
.. include:: /includes/extracts/bson-deserialization-findOneAndDelete.rst
Output
:returns:
------
Returns the document that was deleted. If no document matched the
An object for the document that was deleted, or ``null`` if no document
filter, the returned document is ``null``
.
matched the query
.
Examples
Examples
--------
--------
The following example deletes the document with ``restaurant_id`` of
The following example finds and deletes the document with ``restaurant_id`` of
``40375376`` from the ``restaurants`` collection in the ``example``
``"40375376"`` from the ``restaurants`` collection in the ``example`` database:
database:
.. code-block:: php
.. code-block:: php
<?php
<?php
$database = new MongoDB\Client;
$collection = (new MongoDB\Client)->example->restaurants;
$collection = $database->selectCollection('example','restaurants');
$deletedRestaurant = $collection->findOneAndDelete(
$deletedRestaurant = $collection->findOneAndDelete(
[ 'restaurant_id' => '40375376' ],
[ 'restaurant_id' => '40375376' ],
[ 'projection' => [ 'name' => 1,
[
'projection' => [
'name' => 1,
'borough' => 1,
'borough' => 1,
'restaurant_id' => 1
'restaurant_id' => 1,
]
],
]
]
);
);
The output would resemble:
var_dump($deletedRestaurant);
.. code-block:: none
The output would then resemble::
object(stdClass)#14 (4) {
object(stdClass)#14 (4) {
["_id"]=>
["_id"]=>
...
@@ -80,10 +78,9 @@ The output would resemble:
...
@@ -80,10 +78,9 @@ The output would resemble:
string(8) "40375376"
string(8) "40375376"
}
}
.. seealso::
.. seealso::
- :phpmethod:`MongoDB\\Collection::findOneAnd
Update
`
- :phpmethod:`MongoDB\\Collection::findOneAnd
Replace()
`
- :phpmethod:`MongoDB\\Collection::findOneAnd
Replace
`
- :phpmethod:`MongoDB\\Collection::findOneAnd
Update()
`
- :manual:`findAndModify </reference/command/findAndModify>`
- :manual:`findAndModify </reference/command/findAndModify>`
command
command
reference in the MongoDB manual
reference in the MongoDB manual
docs/reference/method/MongoDBCollection-findOneAndReplace.txt
View file @
b33e5a5a
...
@@ -10,11 +10,10 @@ MongoDB\\Collection::findOneAndReplace()
...
@@ -10,11 +10,10 @@ MongoDB\\Collection::findOneAndReplace()
:depth: 1
:depth: 1
:class: singlecol
:class: singlecol
Definition
Definition
----------
----------
.. phpmethod:: MongoDB\\Collection::findOneAndReplace
.. phpmethod:: MongoDB\\Collection::findOneAndReplace
()
Finds a single document matching the query and replaces it.
Finds a single document matching the query and replaces it.
...
@@ -22,7 +21,8 @@ Definition
...
@@ -22,7 +21,8 @@ Definition
function findOneAndReplace($filter, $replacement, array $options = []): object|null
function findOneAndReplace($filter, $replacement, array $options = []): object|null
``findOneAndReplace()`` supports the following parameters:
:phpmethod:`MongoDB\\Collection::findOneAndReplace()` has the following
parameters:
.. include:: /includes/apiargs/MongoDBCollection-method-findOneAndReplace-param.rst
.. include:: /includes/apiargs/MongoDBCollection-method-findOneAndReplace-param.rst
...
@@ -32,18 +32,18 @@ Definition
...
@@ -32,18 +32,18 @@ Definition
.. include:: /includes/extracts/bson-deserialization-findOneAndReplace.rst
.. include:: /includes/extracts/bson-deserialization-findOneAndReplace.rst
Output
:returns:
------
By default, returns the original document. To return the *new*
An object for either the original or the replaced document, depending on
document, use the ``returnDocument`` option. If no document matched
the specified value of the ``returnDocument`` option. By default, the
the query, returns ``null``.
original document is returned. If no document matched the query, ``null``
is returned.
Examples
Examples
--------
--------
Consider the following document in the ``restaurants`` collection in
Consider the following document in the ``restaurants`` collection in
the
the
``example`` database:
``example`` database:
.. code-block:: javascript
.. code-block:: javascript
...
@@ -81,31 +81,30 @@ the ``example`` database:
...
@@ -81,31 +81,30 @@ the ``example`` database:
"restaurant_id" : "41220906"
"restaurant_id" : "41220906"
}
}
The following operation replaces the document with ``restaurant_id
:
The following operation replaces the document with ``restaurant_id
`` of
41220906`` with the new specified
document:
``"41220906"`` with a new
document:
.. code-block:: php
.. code-block:: php
<?php
<?php
$collection =
$database->selectCollection('example','restaurants')
;
$collection =
(new MongoDB\Client)->example->restaurants
;
$
update
Restaurant = $collection->findOneAndReplace(
$
replaced
Restaurant = $collection->findOneAndReplace(
[ 'restaurant_id' => '41220906' ],
[ 'restaurant_id' => '41220906' ],
[ 'Borough' => 'Staten Island',
[
'Borough' => 'Staten Island',
'cuisine' => 'Italian',
'cuisine' => 'Italian',
'grades' => [],
'grades' => [],
'name' => 'Staten Island Pastaria',
'name' => 'Staten Island Pastaria',
'restaurant_id' => '999999999',
'restaurant_id' => '999999999',
],
],
[ 'returnDocument' => MongoDB\Operation\FindOneAnd
Updat
e::RETURN_DOCUMENT_AFTER ]
[ 'returnDocument' => MongoDB\Operation\FindOneAnd
Replac
e::RETURN_DOCUMENT_AFTER ]
);
);
var_dump($replacedRestaurant)
The output would then resemble::
var_dump($updateRestaurant)
The ``var_dump()`` output contains the new document, as in the following::
object(stdClass)#14 (6) {
object(stdClass)#14 (6) {
["_id"]=>
["_id"]=>
...
@@ -128,7 +127,7 @@ The ``var_dump()`` output contains the new document, as in the following::
...
@@ -128,7 +127,7 @@ The ``var_dump()`` output contains the new document, as in the following::
.. seealso::
.. seealso::
- :phpmethod:`MongoDB\\Collection::findOneAndDelete`
- :phpmethod:`MongoDB\\Collection::findOneAndDelete
()
`
- :phpmethod:`MongoDB\\Collection::findOneAndUpdate`
- :phpmethod:`MongoDB\\Collection::findOneAndUpdate
()
`
- :manual:`findAndModify </reference/command/findAndModify>`
- :manual:`findAndModify </reference/command/findAndModify>`
command
command
reference in the MongoDB manual
reference in the MongoDB manual
docs/reference/method/MongoDBCollection-findOneAndUpdate.txt
View file @
b33e5a5a
...
@@ -10,11 +10,10 @@ MongoDB\\Collection::findOneAndUpdate()
...
@@ -10,11 +10,10 @@ MongoDB\\Collection::findOneAndUpdate()
:depth: 1
:depth: 1
:class: singlecol
:class: singlecol
Definition
Definition
----------
----------
.. phpmethod:: MongoDB\\Collection::findOneAndUpdate
.. phpmethod:: MongoDB\\Collection::findOneAndUpdate
()
Finds a single document matching the query and updates it.
Finds a single document matching the query and updates it.
...
@@ -22,7 +21,8 @@ Definition
...
@@ -22,7 +21,8 @@ Definition
function findOneAndUpdate($filter, $update, array $options = []): object|null
function findOneAndUpdate($filter, $update, array $options = []): object|null
``findOneAndUpdate()`` supports the following parameters:
:phpmethod:`MongoDB\\Collection::findOneAndUpdate()` has the following
parameters:
.. include:: /includes/apiargs/MongoDBCollection-method-findOneAndUpdate-param.rst
.. include:: /includes/apiargs/MongoDBCollection-method-findOneAndUpdate-param.rst
...
@@ -32,42 +32,66 @@ Definition
...
@@ -32,42 +32,66 @@ Definition
.. include:: /includes/extracts/bson-deserialization-findOneAndUpdate.rst
.. include:: /includes/extracts/bson-deserialization-findOneAndUpdate.rst
Output
:returns:
------
Returns either the original or the updated document, depending on the
An object for either the original or the updated document, depending on
specified value for the ``returnDocument`` option. By default, the
the specified value of the ``returnDocument`` option. By default, the
original document is returned.
original document is returned. If no document matched the query, ``null``
is returned.
Examples
Examples
--------
--------
The following operation updates the
building number of the restaurant
The following operation updates the
restaurant with ``restaurant_id`` of
with ``restaurant_id : 40361708`` in the ``restaurants`` collection in
``"40361708"`` in the ``restaurants`` collection in the ``example`` database by
the ``example`` database to ``761
``:
setting its building number to ``"761"
``:
.. code-block:: php
.. code-block:: php
<?php
<?php
$database = new MongoDB\Client;
$collection = (new MongoDB\Client)->example->restaurants;
$collection = $database->selectCollection('example','restaurants');
$updateRestaurant = $collection->findOneAndUpdate(
$update
d
Restaurant = $collection->findOneAndUpdate(
[ 'restaurant_id' => '40361708' ],
[ 'restaurant_id' => '40361708' ],
[ '$set' => ['address.building' => '761']],
[ '$set' => [ 'address.building' => '761' ]],
[ 'returnDocument' => MongoDB\Operation\FindOneAndUpdate::RETURN_DOCUMENT_AFTER ]
[
'projection' => [ 'address' => 1 ],
'returnDocument' => MongoDB\Operation\FindOneAndUpdate::RETURN_DOCUMENT_AFTER
]
);
);
var_dump($updatedRestaurant)
var_dump($updateRestaurant)
The output would then resemble::
object(stdClass)#16 (2) {
["_id"]=>
object(MongoDB\BSON\ObjectID)#10 (1) {
["oid"]=>
string(24) "5813a08d29032c6e72d566a7"
}
["address"]=>
object(stdClass)#15 (4) {
["building"]=>
string(3) "761"
["coord"]=>
array(2) {
[0]=>
float(-73.9925306)
[1]=>
float(40.7309346)
}
["street"]=>
string(8) "Broadway"
["zipcode"]=>
string(5) "10003"
}
}
.. seealso::
.. seealso::
- :phpmethod:`MongoDB\\Collection::findOneAndDelete`
- :phpmethod:`MongoDB\\Collection::findOneAndDelete
()
`
- :phpmethod:`MongoDB\\Collection::findOneAndReplace`
- :phpmethod:`MongoDB\\Collection::findOneAndReplace
()
`
- :manual:`findAndModify </reference/command/findAndModify>` command
reference
- :manual:`findAndModify </reference/command/findAndModify>` command
in the MongoDB manual
reference
in the MongoDB manual
docs/reference/method/MongoDBCollection-getCollectionName.txt
View file @
b33e5a5a
...
@@ -4,35 +4,46 @@ MongoDB\\Collection::getCollectionName()
...
@@ -4,35 +4,46 @@ MongoDB\\Collection::getCollectionName()
.. default-domain:: mongodb
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
Definition
----------
----------
.. phpmethod:: MongoDB\\Collection::getCollectionName()
.. phpmethod:: MongoDB\\Collection::getCollectionName()
Returns the name of th
e current
collection.
Returns the name of th
is
collection.
.. code-block:: php
.. code-block:: php
function getCollectionName(): string
function getCollectionName(): string
:returns:
The name of this collection as a string.
Example
Example
-------
-------
The following returns the
name of the collection assigned to
the
The following returns the
collection name for the ``zips`` collection in
the
``
$collection`` variable
``
demo`` database.
.. code-block:: php
.. code-block:: php
<?php
<?php
$collection = (new MongoDB\Client)->demo->zips;
$collection = (new MongoDB\Client)->demo->zips;
echo $collection->getCollectionName();
The ``$collection`` variable uses the :phpmethod:`constructor
echo $collection->getCollectionName();
<MongoDB\\Collection::__construct>` method to select the ``zips``
collection in the ``demo`` database, as such, the printed output would
resemble:
.. code-block:: none
The output would then resemble::
zips
zips
.. seealso::
- :phpmethod:`MongoDB\\Collection::getDatabaseName()`
- :phpmethod:`MongoDB\\Collection::getNamespace()`
docs/reference/method/MongoDBCollection-getDatabaseName.txt
View file @
b33e5a5a
...
@@ -4,35 +4,47 @@ MongoDB\\Collection::getDatabaseName()
...
@@ -4,35 +4,47 @@ MongoDB\\Collection::getDatabaseName()
.. default-domain:: mongodb
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
Definition
----------
----------
.. phpmethod:: MongoDB\\Collection::getDatabaseName()
.. phpmethod:: MongoDB\\Collection::getDatabaseName()
Returns the name of the
current database
.
Returns the name of the
database containing this collection
.
.. code-block:: php
.. code-block:: php
function getDatabaseName(): string
function getDatabaseName(): string
:returns:
The name of the database containing this collection as a string.
Example
Example
-------
-------
The following returns the
name of the database of the collection
The following returns the
database name for the ``zips`` collection in the
assigned to the ``$collection`` variable
``demo`` database.
.. code-block:: php
.. code-block:: php
<?php
<?php
$collection = (new MongoDB\Client)->demo->zips;
$collection = (new MongoDB\Client)->demo->zips;
echo $collection->getDatabaseName();
The ``$collection`` variable uses the :phpmethod:`constructor
echo $collection->getDatabaseName();
<MongoDB\\Collection::__construct>` method to select the ``zips``
collection in the ``demo`` database, as such, the printed output would
resemble:
.. code-block:: none
The output would then resemble::
demo
demo
.. seealso::
- :phpmethod:`MongoDB\\Collection::getCollectionName()`
- :phpmethod:`MongoDB\\Collection::getNamespace()`
docs/reference/method/MongoDBCollection-getManager.txt
View file @
b33e5a5a
...
@@ -17,7 +17,7 @@ Definition
...
@@ -17,7 +17,7 @@ Definition
Accessor for the
Accessor for the
:php:`MongoDB\\Driver\\Manager <class.mongodb-driver-manager>` used by this
:php:`MongoDB\\Driver\\Manager <class.mongodb-driver-manager>` used by this
:phpclass:`C
lient
<MongoDB\\Collection>`.
:phpclass:`C
ollection
<MongoDB\\Collection>`.
.. code-block:: php
.. code-block:: php
...
...
docs/reference/method/MongoDBCollection-getNamespace.txt
View file @
b33e5a5a
...
@@ -4,36 +4,47 @@ MongoDB\\Collection::getNamespace()
...
@@ -4,36 +4,47 @@ MongoDB\\Collection::getNamespace()
.. default-domain:: mongodb
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
Definition
----------
----------
.. phpmethod:: MongoDB\\Collection::getNamespace()
.. phpmethod:: MongoDB\\Collection::getNamespace()
Returns the :term:`namespace` of the collection. A namespace
Returns the :term:`namespace` of the collection. A namespace
is the canonical
is the canonical
name of an index or collection in MongoDB.
name of an index or collection in MongoDB.
.. code-block:: php
.. code-block:: php
function getNamespace(): string
function getNamespace(): string
:returns:
The namespace of this collection as a string.
Example
Example
-------
-------
The following returns the namespace of the
collection
The following returns the namespace of the
``zips`` collection in the ``demo``
assigned to the ``$collection`` variable
database.
.. code-block:: php
.. code-block:: php
<?php
<?php
$collection = (new MongoDB\Client)->demo->zips;
$collection = (new MongoDB\Client)->demo->zips;
echo $collection->getNamespace();
The ``$collection`` variable uses the :phpmethod:`constructor
echo $collection->getNamespace();
<MongoDB\\Collection::__construct>` method to select the ``zips``
collection in the ``demo`` database, as such, the printed output would
resemble:
.. code-block:: none
The output would then resemble::
demo.zips
demo.zips
.. seealso::
- :phpmethod:`MongoDB\\Collection::getCollectionName()`
- :phpmethod:`MongoDB\\Collection::getDatabaseName()`
docs/reference/method/MongoDBCollection-insertMany.txt
View file @
b33e5a5a
...
@@ -10,19 +10,18 @@ MongoDB\\Collection::insertMany()
...
@@ -10,19 +10,18 @@ MongoDB\\Collection::insertMany()
:depth: 1
:depth: 1
:class: singlecol
:class: singlecol
Definition
Definition
----------
----------
.. phpmethod:: MongoDB\\Collection::insertMany
.. phpmethod:: MongoDB\\Collection::insertMany
()
Insert
s one document
.
Insert
multiple documents
.
.. code-block:: php
.. code-block:: php
function insertMany(array $documents, array $options = []): MongoDB\InsertManyResult
function insertMany(array $documents, array $options = []): MongoDB\InsertManyResult
``insertMany()`` support
s the following parameters:
:phpmethod:`MongoDB\\Collection::insertMany()` ha
s the following parameters:
.. include:: /includes/apiargs/MongoDBCollection-method-insertMany-param.rst
.. include:: /includes/apiargs/MongoDBCollection-method-insertMany-param.rst
...
@@ -30,47 +29,44 @@ Definition
...
@@ -30,47 +29,44 @@ Definition
.. include:: /includes/apiargs/MongoDBCollection-method-insertMany-option.rst
.. include:: /includes/apiargs/MongoDBCollection-method-insertMany-option.rst
Output
:returns:
------
Returns a ``MongoDB\InsertManyResult`` object.
A :phpclass:`MongoDB\\InsertManyResult` object, which encapsulates a
:php:`MongoDB\\Driver\\WriteResult <class.mongodb-driver-writeresult>`
object.
Example
Example
-------
-------
.. start-crud-include
.. start-crud-include
The following operation inserts two documents into the ``users``
The following operation inserts two documents into the ``users``
collection
collection
in the ``example`` database:
in the ``example`` database:
.. code-block:: php
.. code-block:: php
<?php
<?php
$database = new MongoDB\Client;
$collection = (new MongoDB\Client)->example->users;
$collection = $database->selectCollection('users','restaurants');
$newUsers = $collection->insertMany(
$insertManyResult = $collection->insertMany([
[
[
[
'username' => 'admin',
'username' => 'admin',
'email' => 'admin@example.com',
'email' => 'admin@example.com',
'name' => 'Admin User'
'name' => 'Admin User'
,
],
],
[
[
'username' => 'test',
'username' => 'test',
'email' => 'test@example.com',
'email' => 'test@example.com',
'name' => 'Test User'
'name' => 'Test User',
],
],
]
]);
);
printf("Inserted %d document(s)\n", $insertManyResult->getInsertedCount());
printf("Inserted %d document(s)\n", $newUsers->getInsertedCount());
var_dump($insertManyResult->getInsertedIds());
var_dump($newUsers->getInsertedIds());
The output would resemble::
The output would
then
resemble::
Inserted 2 document(s)
Inserted 2 document(s)
array(2) {
array(2) {
...
@@ -90,8 +86,8 @@ The output would resemble::
...
@@ -90,8 +86,8 @@ The output would resemble::
.. seealso::
.. seealso::
- :phpmethod:`MongoDB\\Collection::
bulkWrite
`
- :phpmethod:`MongoDB\\Collection::
insertOne()
`
- :phpmethod:`MongoDB\\Collection::
insertOne
`
- :phpmethod:`MongoDB\\Collection::
bulkWrite()
`
- :doc:`/tutorial/crud`
- :doc:`/tutorial/crud`
- :manual:`insert </reference/command/insert>` command reference
- :manual:`insert </reference/command/insert>` command reference
in the
in the
MongoDB manual
MongoDB manual
docs/reference/method/MongoDBCollection-insertOne.txt
View file @
b33e5a5a
...
@@ -10,19 +10,18 @@ MongoDB\\Collection::insertOne()
...
@@ -10,19 +10,18 @@ MongoDB\\Collection::insertOne()
:depth: 1
:depth: 1
:class: singlecol
:class: singlecol
Definition
Definition
----------
----------
.. phpmethod:: MongoDB\\Collection::insertOne
.. phpmethod:: MongoDB\\Collection::insertOne
()
Insert
s
one document.
Insert one document.
.. code-block:: php
.. code-block:: php
function insertOne($document, array $options = []): MongoDB\InsertOneResult
function insertOne($document, array $options = []): MongoDB\InsertOneResult
``insertOne()`` support
s the following parameters:
:phpmethod:`MongoDB\\Collection::insertOne()` ha
s the following parameters:
.. include:: /includes/apiargs/MongoDBCollection-method-insertOne-param.rst
.. include:: /includes/apiargs/MongoDBCollection-method-insertOne-param.rst
...
@@ -30,23 +29,50 @@ Definition
...
@@ -30,23 +29,50 @@ Definition
.. include:: /includes/apiargs/MongoDBCollection-method-insertOne-option.rst
.. include:: /includes/apiargs/MongoDBCollection-method-insertOne-option.rst
Output
:returns:
------
Returns a ``MongoDB\InsertOneResult`` object.
A :phpclass:`MongoDB\\InsertOneResult` object, which encapsulates a
:php:`MongoDB\\Driver\\WriteResult <class.mongodb-driver-writeresult>`
object.
Example
Example
-------
-------
The following operation inserts a document into the ``users``
.. start-crud-include
collection in the ``example`` database:
The following operation inserts a document into the ``users`` collection in the
``example`` database:
.. code-block:: php
<?php
$collection = (new MongoDB\Client)->example->users;
$insertOneResult = $collection->insertOne([
'username' => 'admin',
'email' => 'admin@example.com',
'name' => 'Admin User',
]);
printf("Inserted %d document(s)\n", $insertOneResult->getInsertedCount());
var_dump($insertOneResult->getInsertedId());
The output would then resemble::
Inserted 1 document(s)
object(MongoDB\BSON\ObjectID)#11 (1) {
["oid"]=>
string(24) "579a25921f417dd1e5518141"
}
..
include:: /includes/example-insertOne.rst
..
end-crud-include
.. seealso::
.. seealso::
- :phpmethod:`MongoDB\\Collection::
bulkWrite
`
- :phpmethod:`MongoDB\\Collection::
insertMany()
`
- :phpmethod:`MongoDB\\Collection::
insertMany
`
- :phpmethod:`MongoDB\\Collection::
bulkWrite()
`
- :doc:`/tutorial/crud`
- :doc:`/tutorial/crud`
- :manual:`insert </reference/command/insert>` command reference
- :manual:`insert </reference/command/insert>` command reference
in the
in the
MongoDB manual
MongoDB manual
docs/reference/method/MongoDBCollection-listIndexes.txt
View file @
b33e5a5a
...
@@ -4,7 +4,7 @@ MongoDB\\Collection::listIndexes()
...
@@ -4,7 +4,7 @@ MongoDB\\Collection::listIndexes()
.. default-domain:: mongodb
.. default-domain:: mongodb
.. contents::
.. contents::
On this page
:local:
:local:
:backlinks: none
:backlinks: none
:depth: 1
:depth: 1
...
@@ -13,16 +13,15 @@ MongoDB\\Collection::listIndexes()
...
@@ -13,16 +13,15 @@ MongoDB\\Collection::listIndexes()
Definition
Definition
----------
----------
.. phpmethod:: MongoDB\\Collection::listIndexes(
$options
)
.. phpmethod:: MongoDB\\Collection::listIndexes()
Returns information for all indexes for th
e
collection.
Returns information for all indexes for th
is
collection.
.. code-block:: php
.. code-block:: php
function listIndexes(array $options = []): MongoDB\Model\IndexInfoIterator
function listIndexes(array $options = []): MongoDB\Model\IndexInfoIterator
:phpmethod:`MongoDB\\Collection::listIndexes` supports the
:phpmethod:`MongoDB\\Collection::listIndexes()` has the following parameters:
following parameter:
.. include:: /includes/apiargs/MongoDBCollection-method-listIndexes-param.rst
.. include:: /includes/apiargs/MongoDBCollection-method-listIndexes-param.rst
...
@@ -30,30 +29,25 @@ Definition
...
@@ -30,30 +29,25 @@ Definition
.. include:: /includes/apiargs/MongoDBCollection-method-listIndexes-option.rst
.. include:: /includes/apiargs/MongoDBCollection-method-listIndexes-option.rst
Output
:returns:
------
Elements in the returned iterator are ``MongoDB\Model\IndexInfo``
objects.
A traversable :phpclass:`MongoDB\\Model\IndexInfoIterator`, which
contains an :phpclass:`MongoDB\\Model\IndexInfo` object for each index for
the collection.
Example
Example
-------
-------
The following
lists information about the indexes on the collection
The following
example lists all of the indexes for the ``restaurants``
assigned to the ``$collection`` variable
collection in the ``example`` database:
.. code-block:: php
.. code-block:: php
<?php
<?php
$database = new MongoDB\Client;
$collection = (new MongoDB\Client)->example->restaurants;
$collection = $database->selectCollection('example','restaurants');
$indexes = $collection->listIndexes();
foreach ($collection->listIndexes() as $index) {
foreach ($indexes as $index) {
var_dump($index);
var_dump($index);
}
}
...
@@ -99,14 +93,12 @@ The output would then resemble::
...
@@ -99,14 +93,12 @@ The output would then resemble::
string(19) "example.restaurants"
string(19) "example.restaurants"
}
}
.. seealso::
.. seealso::
- :doc:`/tutorial/indexes`
- :doc:`/tutorial/indexes`
- :manual:`listIndexes </reference/command/listIndexes>` command reference in
- :manual:`listIndexes command </reference/command/listIndexes>` in the MongoDB manual.
the MongoDB manual
- :manual:`Index documentation </core/indexes>` in the MongoDB manual
- :manual:`Index documentation </core/indexes>` in the MongoDB manual.
- `Enumerating Collections
- `MongoDB Specification: Enumerating Collections
<https://github.com/mongodb/specifications/blob/master/source/enumerate-indexes.rst>`_
<https://github.com/mongodb/specifications/blob/master/source/enumerate-indexes.rst>`_
specification
docs/reference/method/MongoDBCollection-replaceOne.txt
View file @
b33e5a5a
...
@@ -10,19 +10,20 @@ MongoDB\\Collection::replaceOne()
...
@@ -10,19 +10,20 @@ MongoDB\\Collection::replaceOne()
:depth: 1
:depth: 1
:class: singlecol
:class: singlecol
Definition
Definition
----------
----------
.. phpmethod:: MongoDB\\Collection::replaceOne
.. phpmethod:: MongoDB\\Collection::replaceOne
()
Replaces at most one document that matches the filter.
Replace at most one document that matches the filter criteria. If multiple
documents match the filter criteria, only the :term:`first <natural order>`
matching document will be replaced.
.. code-block:: php
.. code-block:: php
function replaceOne($filter, $replacement, array $options = []): MongoDB\UpdateResult
function replaceOne($filter, $replacement, array $options = []): MongoDB\UpdateResult
``replaceOne()`` support
s the following parameters:
:phpmethod:`MongoDB\\Collection::replaceOne()` ha
s the following parameters:
.. include:: /includes/apiargs/MongoDBCollection-method-replaceOne-param.rst
.. include:: /includes/apiargs/MongoDBCollection-method-replaceOne-param.rst
...
@@ -30,27 +31,26 @@ Definition
...
@@ -30,27 +31,26 @@ Definition
.. include:: /includes/apiargs/MongoDBCollection-method-replaceOne-option.rst
.. include:: /includes/apiargs/MongoDBCollection-method-replaceOne-option.rst
Output
:returns:
------
Returns a ``MongoDB\UpdateResult`` object.
A :phpclass:`MongoDB\\UpdateResult` object, which encapsulates a
:php:`MongoDB\\Driver\\WriteResult <class.mongodb-driver-writeresult>`
object.
Example
Example
-------
-------
The following
operation replaces the document with ``restaurant_id``
The following
example replaces the document with ``restaurant_id`` of
``
40356068
`` in the ``restaurants`` collection in the ``example`` database:
``
"40356068"
`` in the ``restaurants`` collection in the ``example`` database:
.. code-block:: php
.. code-block:: php
<?php
<?php
$database = new MongoDB\Client;
$collection = (new MongoDB\Client)->example->restaurants;
$collection = $database->selectCollection('users','restaurants');
$
replacemen
t = $collection->replaceOne(
$
updateResul
t = $collection->replaceOne(
[
'restaurant_id' => '40356068'
],
[
'restaurant_id' => '40356068'
],
[
[
'name' => 'New Restaurant',
'name' => 'New Restaurant',
'restaurant_id' => '99988877',
'restaurant_id' => '99988877',
...
@@ -60,55 +60,19 @@ The following operation replaces the document with ``restaurant_id``
...
@@ -60,55 +60,19 @@ The following operation replaces the document with ``restaurant_id``
]
]
);
);
printf("Matched %d document(s)\n", $updateResult->getMatchedCount());
printf("Modified %d document(s)\n", $updateResult->getModifiedCount());
The output would then resemble::
var_dump($replacement);
Matched 1 document(s)
Modified 1 document(s)
The output would resemble:
.. code-block:: none
object(MongoDB\UpdateResult)#13 (2) {
["writeResult":"MongoDB\UpdateResult":private]=>
object(MongoDB\Driver\WriteResult)#12 (9) {
["nInserted"]=>
int(0)
["nMatched"]=>
int(1)
["nModified"]=>
int(1)
["nRemoved"]=>
int(0)
["nUpserted"]=>
int(0)
["upsertedIds"]=>
array(0) {
}
["writeErrors"]=>
array(0) {
}
["writeConcernError"]=>
NULL
["writeConcern"]=>
array(4) {
["w"]=>
NULL
["wmajority"]=>
bool(false)
["wtimeout"]=>
int(0)
["journal"]=>
NULL
}
}
["isAcknowledged":"MongoDB\UpdateResult":private]=>
bool(true)
}
.. seealso::
.. seealso::
- :phpmethod:`MongoDB\\Collection::
bulkWrite
`
- :phpmethod:`MongoDB\\Collection::
updateMany()
`
- :phpmethod:`MongoDB\\Collection::update
Many
`
- :phpmethod:`MongoDB\\Collection::update
One()
`
- :phpmethod:`MongoDB\\Collection::
updateOne
`
- :phpmethod:`MongoDB\\Collection::
bulkWrite()
`
- :doc:`/tutorial/crud`
- :doc:`/tutorial/crud`
- :manual:`update </reference/command/update>` command reference
- :manual:`update </reference/command/update>` command reference
in the
in the
MongoDB manual
MongoDB manual
docs/reference/method/MongoDBCollection-updateMany.txt
View file @
b33e5a5a
...
@@ -10,19 +10,18 @@ MongoDB\\Collection::updateMany()
...
@@ -10,19 +10,18 @@ MongoDB\\Collection::updateMany()
:depth: 1
:depth: 1
:class: singlecol
:class: singlecol
Definition
Definition
----------
----------
.. phpmethod:: MongoDB\\Collection::updateMany
.. phpmethod:: MongoDB\\Collection::updateMany
()
Update
s
all documents that match the filter criteria.
Update all documents that match the filter criteria.
.. code-block:: php
.. code-block:: php
function updateMany($filter, $update, array $options = []): MongoDB\UpdateResult
function updateMany($filter, $update, array $options = []): MongoDB\UpdateResult
``updateMany()`` support
s the following parameters:
:phpmethod:`MongoDB\\Collection::updateMany()` ha
s the following parameters:
.. include:: /includes/apiargs/MongoDBCollection-method-updateMany-param.rst
.. include:: /includes/apiargs/MongoDBCollection-method-updateMany-param.rst
...
@@ -30,80 +29,40 @@ Definition
...
@@ -30,80 +29,40 @@ Definition
.. include:: /includes/apiargs/MongoDBCollection-method-updateMany-option.rst
.. include:: /includes/apiargs/MongoDBCollection-method-updateMany-option.rst
Output
:returns:
------
Returns a ``MongoDB\UpdateResult`` object.
A :phpclass:`MongoDB\\UpdateResult` object, which encapsulates a
:php:`MongoDB\\Driver\\WriteResult <class.mongodb-driver-writeresult>`
object.
Examples
Examples
--------
--------
The following
operation adds a an ``active`` field to all of the documents
The following
example updates all of the documents with the ``borough`` of
with ``borough: Queens`` with value
``true``:
``"Queens"`` by setting the ``active`` field to
``true``:
.. code-block:: php
.. code-block:: php
$database = new MongoDB\Client;
$collection = (new MongoDB\Client)->example->restaurants;
$collection = $database->selectCollection('example','restaurants');
$update = $collection->updateMany(
$updateResult = $collection->updateMany(
[ 'borough' => 'Queens'],
[ 'borough' => 'Queens' ],
[
[ '$set' => [ 'active' => 'True' ]]
'$set' => [
'active' => 'True'
]
]
);
);
printf("Matched %d document(s)\n", $updateResult->getMatchedCount());
printf("Modified %d document(s)\n", $updateResult->getModifiedCount());
var_dump($update);
The output would then resemble::
The output would then resemble::
object(MongoDB\UpdateResult)#13 (2) {
Matched 5656 document(s)
["writeResult":"MongoDB\UpdateResult":private]=>
Modified 5656 document(s)
object(MongoDB\Driver\WriteResult)#12 (9) {
["nInserted"]=>
int(0)
["nMatched"]=>
int(5656)
["nModified"]=>
int(5656)
["nRemoved"]=>
int(0)
["nUpserted"]=>
int(0)
["upsertedIds"]=>
array(0) {
}
["writeErrors"]=>
array(0) {
}
["writeConcernError"]=>
NULL
["writeConcern"]=>
array(4) {
["w"]=>
NULL
["wmajority"]=>
bool(false)
["wtimeout"]=>
int(0)
["journal"]=>
NULL
}
}
["isAcknowledged":"MongoDB\UpdateResult":private]=>
bool(true)
}
.. seealso::
.. seealso::
- :phpmethod:`MongoDB\\Collection::
bulkWrite
`
- :phpmethod:`MongoDB\\Collection::
replaceOne()
`
- :phpmethod:`MongoDB\\Collection::
replaceOne
`
- :phpmethod:`MongoDB\\Collection::
updateOne()
`
- :phpmethod:`MongoDB\\Collection::
updateOne
`
- :phpmethod:`MongoDB\\Collection::
bulkWrite()
`
- :doc:`/tutorial/crud`
- :doc:`/tutorial/crud`
- :manual:`update </reference/command/update>` command reference
- :manual:`update </reference/command/update>` command reference
in the
in the MongoDB manual.
MongoDB manual
docs/reference/method/MongoDBCollection-updateOne.txt
View file @
b33e5a5a
...
@@ -10,19 +10,20 @@ MongoDB\\Collection::updateOne()
...
@@ -10,19 +10,20 @@ MongoDB\\Collection::updateOne()
:depth: 1
:depth: 1
:class: singlecol
:class: singlecol
Definition
Definition
----------
----------
.. phpmethod:: MongoDB\\Collection::updateOne
.. phpmethod:: MongoDB\\Collection::updateOne
()
Finds a single document matching the query and updates it.
Update at most one document that matches the filter criteria. If multiple
documents match the filter criteria, only the :term:`first <natural order>`
matching document will be updated.
.. code-block:: php
.. code-block:: php
function updateOne($filter, $update, array $options = []): MongoDB\UpdateResult
function updateOne($filter, $update, array $options = []): MongoDB\UpdateResult
``updateOne()`` support
s the following parameters:
:phpmethod:`MongoDB\\Collection::updateOne()` ha
s the following parameters:
.. include:: /includes/apiargs/MongoDBCollection-method-updateOne-param.rst
.. include:: /includes/apiargs/MongoDBCollection-method-updateOne-param.rst
...
@@ -30,81 +31,40 @@ Definition
...
@@ -30,81 +31,40 @@ Definition
.. include:: /includes/apiargs/MongoDBCollection-method-updateOne-option.rst
.. include:: /includes/apiargs/MongoDBCollection-method-updateOne-option.rst
Output
:returns:
------
Returns a ``MongoDB\UpdateResult`` object.
A :phpclass:`MongoDB\\UpdateResult` object, which encapsulates a
:php:`MongoDB\\Driver\\WriteResult <class.mongodb-driver-writeresult>`
object.
Examples
Examples
--------
--------
The following
operation updates the ``name`` of the restaurant with
The following
example updates one document with the ``restaurant_id`` of
``
restaurant_id: 40356151`` to "Brunos on Astoria"
:
``
"40356151"`` by setting the ``name`` field to ``"Brunos on Astoria"``
:
.. code-block:: php
.. code-block:: php
$database = new MongoDB\Client;
$collection = (new MongoDB\Client)->example->restaurants;
$collection = $database->selectCollection('example','restaurants');
$update = $collection->updateOne(
$updateResult = $collection->updateOne(
[ 'restaurant_id' => '40356151'],
[ 'restaurant_id' => '40356151' ],
[
[ '$set' => [ 'name' => 'Brunos on Astoria' ]]
'$set' => [
'name' => 'Brunos on Astoria'
]
]
);
);
printf("Matched %d document(s)\n", $updateResult->getMatchedCount());
printf("Modified %d document(s)\n", $updateResult->getModifiedCount());
var_dump($update);
The output would then resemble::
The output would then resemble::
object(MongoDB\UpdateResult)#13 (2) {
Matched 1 document(s)
["writeResult":"MongoDB\UpdateResult":private]=>
Modified 1 document(s)
object(MongoDB\Driver\WriteResult)#12 (9) {
["nInserted"]=>
int(0)
["nMatched"]=>
int(1)
["nModified"]=>
int(1)
["nRemoved"]=>
int(0)
["nUpserted"]=>
int(0)
["upsertedIds"]=>
array(0) {
}
["writeErrors"]=>
array(0) {
}
["writeConcernError"]=>
NULL
["writeConcern"]=>
array(4) {
["w"]=>
NULL
["wmajority"]=>
bool(false)
["wtimeout"]=>
int(0)
["journal"]=>
NULL
}
}
["isAcknowledged":"MongoDB\UpdateResult":private]=>
bool(true)
}
.. seealso::
.. seealso::
- :phpmethod:`MongoDB\\Collection::
bulkWrite
`
- :phpmethod:`MongoDB\\Collection::
replaceOne()
`
- :phpmethod:`MongoDB\\Collection::
replaceOne
`
- :phpmethod:`MongoDB\\Collection::
updateMany()
`
- :phpmethod:`MongoDB\\Collection::
updateMany
`
- :phpmethod:`MongoDB\\Collection::
bulkWrite()
`
- :doc:`/tutorial/crud`
- :doc:`/tutorial/crud`
- :manual:`update </reference/command/update>` command reference
- :manual:`update </reference/command/update>` command reference
in the
in the MongoDB manual.
MongoDB manual
docs/reference/method/MongoDBCollection-withOptions.txt
View file @
b33e5a5a
...
@@ -4,19 +4,24 @@ MongoDB\\Collection::withOptions()
...
@@ -4,19 +4,24 @@ MongoDB\\Collection::withOptions()
.. default-domain:: mongodb
.. default-domain:: mongodb
.. contents:: On this page
:local:
:backlinks: none
:depth: 1
:class: singlecol
Definition
Definition
----------
----------
.. phpmethod:: MongoDB\\Collection::withOptions(
$options
)
.. phpmethod:: MongoDB\\Collection::withOptions()
Returns a clone of the
collection
, but with different options.
Returns a clone of the
Collection object
, but with different options.
.. code-block:: php
.. code-block:: php
function withOptions(array $options = []): MongoDB\Collection
function withOptions(array $options = []): MongoDB\Collection
:phpmethod:`MongoDB\\Collection::withOptions` supports the
:phpmethod:`MongoDB\\Collection::withOptions()` has the following parameters:
following parameter:
.. include:: /includes/apiargs/MongoDBCollection-method-withOptions-param.rst
.. include:: /includes/apiargs/MongoDBCollection-method-withOptions-param.rst
...
@@ -24,26 +29,26 @@ Definition
...
@@ -24,26 +29,26 @@ Definition
.. include:: /includes/apiargs/MongoDBCollection-method-withOptions-option.rst
.. include:: /includes/apiargs/MongoDBCollection-method-withOptions-option.rst
:returns:
A :phpclass:`MongoDB\\Collection` object.
Example
Example
-------
-------
The following example creates a new collection based on the
The following example clones an existing Collection object with a new read
``restaurants`` collection in the ``example`` database with a custom
preference:
read preference:
.. code-block:: php
.. code-block:: php
<?php
<?php
$database = new MongoDB\Client;
$collection = (new MongoDB\Client)->selectCollect('demo', 'restaurants');
$sourceCollection = $database->selectCollection('example','restaurants');
$newCollection = $sourceCollection->withOptions([
$newCollection = $sourceCollection->withOptions([
'readPreference' => new MongoDB\Driver\ReadPreference(MongoDB\Driver\ReadPreference::RP_SECONDARY),
'readPreference' => new MongoDB\Driver\ReadPreference(MongoDB\Driver\ReadPreference::RP_SECONDARY),
]);
]);
.. seealso::
.. seealso::
- :phpmethod:`MongoDB\\Collection::__construct`
- :phpmethod:`MongoDB\\Collection::__construct
()
`
docs/reference/method/MongoDBCollection__construct.txt
View file @
b33e5a5a
...
@@ -13,7 +13,7 @@ MongoDB\\Collection::__construct()
...
@@ -13,7 +13,7 @@ MongoDB\\Collection::__construct()
Definition
Definition
----------
----------
.. phpmethod:: MongoDB\\Collection::__construct(
$manager, $databaseName, $collectionName, $options
)
.. phpmethod:: MongoDB\\Collection::__construct()
Constructs a new :phpclass:`Collection <MongoDB\\Collection>` instance.
Constructs a new :phpclass:`Collection <MongoDB\\Collection>` instance.
...
@@ -25,20 +25,24 @@ Definition
...
@@ -25,20 +25,24 @@ Definition
.. include:: /includes/apiargs/MongoDBCollection-method-construct-param.rst
.. include:: /includes/apiargs/MongoDBCollection-method-construct-param.rst
:phpmethod:`MongoDB\\Collection::__construct` supports the following
The ``$options`` parameter supports the following options:
options:
.. include:: /includes/apiargs/
common
-option.rst
.. include:: /includes/apiargs/
MongoDBCollection-method-construct
-option.rst
If you construct the Collection explicitly, the Collection inherits
Behavior
any options from the ``Manager`` object. If you select the Collection
--------
from a :phpclass:`Client <MongoDB\\Client>` or :phpclass:`Database
<MongoDB\\Database>` object, the Collection inherits its options
If you construct a Collection explicitly, the Collection inherits any options
from that object.
from the :php:`MongoDB\\Driver\\Manager <class.mongodb-driver-manager>` object.
If you select the Collection from a :phpclass:`Client <MongoDB\\Client>` or
:phpclass:`Database <MongoDB\\Database>` object, the Collection inherits its
options from that object.
.. todo: add an example
.. todo: add an example
.. seealso::
.. seealso::
- :phpmethod:`MongoDB\\Collection::withOptions`
- :phpmethod:`MongoDB\\Collection::withOptions()`
- :phpmethod:`MongoDB\\Database::selectCollection`
- :phpmethod:`MongoDB\\Client::selectCollection()`
- :phpmethod:`MongoDB\\Database::selectCollection()`
- :phpmethod:`MongoDB\\Database::__get()`
docs/tutorial/crud.txt
View file @
b33e5a5a
...
@@ -33,12 +33,13 @@ The :phpmethod:`MongoDB\\Collection::insertOne` method inserts a single
...
@@ -33,12 +33,13 @@ The :phpmethod:`MongoDB\\Collection::insertOne` method inserts a single
document into MongoDB and returns an instance of ``MongoDB\InsertOneResult``,
document into MongoDB and returns an instance of ``MongoDB\InsertOneResult``,
which you can use to access the IDs of the inserted document.
which you can use to access the IDs of the inserted document.
..
basic insertOne exampl
e:
..
this uses the insertMany example from the method referenc
e:
.. include:: /includes/example-insertOne.rst
.. include:: /reference/method/MongoDBCollection-insertOne.txt
:start-after: start-crud-include
:end-before: end-crud-include
The output includes the ``insertedId`` property, which contains the
The output includes the ID of the inserted document.
ID of the inserted document.
If you include an ``_id`` value when inserting a document, MongoDB checks
If you include an ``_id`` value when inserting a document, MongoDB checks
to ensure that the ``_id`` value is unique for the collection. If the
to ensure that the ``_id`` value is unique for the collection. If the
...
@@ -324,8 +325,8 @@ collection data. The |php-library|\'s
...
@@ -324,8 +325,8 @@ collection data. The |php-library|\'s
:phpmethod:`MongoDB\\Collection::aggregate` method returns a
:phpmethod:`MongoDB\\Collection::aggregate` method returns a
:php:`traversable <traversable>` object, which you can iterate upon to
:php:`traversable <traversable>` object, which you can iterate upon to
access the results of the aggregation operation. Refer to the
access the results of the aggregation operation. Refer to the
:phpmethod:`MongoDB\\Collection::aggregate` method's :ref:`
output
:phpmethod:`MongoDB\\Collection::aggregate` method's :ref:`
behavior
reference <php-agg-method-
output
>` for more about the method's output.
reference <php-agg-method-
behavior
>` for more about the method's output.
The following example lists the 5 US states with the most zip codes
The following example lists the 5 US states with the most zip codes
associated with them:
associated with them:
...
...
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