apiargs-MongoDBDatabase-method-createCollection-option.yaml 6.61 KB
Newer Older
1 2 3 4
arg_name: option
name: autoIndexId
type: boolean
description: |
5 6
  Specify ``false`` to disable the automatic creation of an index on the ``_id``
  field.
7 8 9

  .. important::

10
     For replica sets, do not set ``autoIndexId`` to ``false``.
11

12
  .. deprecated:: 3.2. The ``autoIndexId`` option will be removed in MongoDB 3.4.
13
interface: phpmethod
14
operation: ~
15 16 17 18 19 20
optional: true
---
arg_name: option
name: capped
type: boolean
description: |
21 22
  To create a capped collection, specify ``true``. If you specify ``true``, you
  must also set a maximum size in the ``size`` option.
23
interface: phpmethod
24
operation: ~
25
optional: true
26 27 28 29 30 31 32
---
source:
  file: apiargs-MongoDBCollection-common-option.yaml
  ref: collation
pre: |
  Specifies the :manual:`collation
  </reference/bson-type-comparison-order/#collation>` for the collection.
33 34
---
arg_name: option
35
name: flags
36 37
type: integer
description: |
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
  Available for the MMAPv1 storage engine only to set the ``usePowerOf2Sizes``
  and ``noPadding`` flags.

  The |php-library| provides constants that you can combine with a :php:`bitwise
  OR operator <language.operators.bitwise>` to set the flag values:

  - ``MongoDB\Operation\CreateCollection::USE_POWER_OF_2_SIZES``: ``1``
  - ``MongoDB\Operation\CreateCollection::NO_PADDING``: ``2``

  Defaults to ``1``.

  .. note::

     MongoDB 3.0 and later ignores the ``usePowerOf2Sizes`` flag. See
     :manual:`collMod </reference/command/collMod>` and
     :manual:`db.createCollection()
     </reference/method/db.createCollection>` for more information.
55
interface: phpmethod
56
operation: ~
57
optional: true
58 59
---
arg_name: option
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
name: indexOptionDefaults
type: array|object
description: |
  Allows users to specify a default configuration for indexes when creating a
  collection.

  The ``indexOptionDefaults`` option accepts a ``storageEngine`` document,
  which should take the following form::

     { <storage-engine-name>: <options> }

  Storage engine configurations specified when creating indexes are validated
  and logged to the :term:`oplog` during replication to support replica sets
  with members that use different storage engines.
interface: phpmethod
75
operation: ~
76 77 78
optional: true
---
arg_name: option
79 80 81
name: max
type: integer
description: |
82 83 84 85 86 87
  The maximum number of documents allowed in the capped collection. The ``size``
  option takes precedence over this limit. If a capped collection reaches the
  ``size`` limit before it reaches the maximum number of documents, MongoDB
  removes old documents. If you prefer to use the ``max`` limit, ensure that the
  ``size`` limit, which is required for a capped collection, is sufficient to
  contain the maximum number of documents.
88
interface: phpmethod
89
operation: ~
90
optional: true
91 92 93 94 95
---
source:
  file: apiargs-common-option.yaml
  ref: maxTimeMS
---
96 97 98
source:
  file: apiargs-common-option.yaml
  ref: session
99 100
post: |
  .. versionadded:: 1.3
101
---
102 103 104 105 106 107 108 109 110
arg_name: option
name: size
type: integer
description: |
  Specify a maximum size in bytes for a capped collection. Once a capped
  collection reaches its maximum size, MongoDB removes the older documents to
  make space for the new documents. The ``size`` option is required for capped
  collections and ignored for other collections.
interface: phpmethod
111
operation: ~
112
optional: true
113 114 115
---
arg_name: option
name: storageEngine
116
type: array|object
117 118 119 120 121 122 123 124 125 126 127 128 129
description: |
  Available for the WiredTiger storage engine only.

  Allows users to specify configuration to the storage engine on a
  per-collection basis when creating a collection. The value of the
  ``storageEngine`` option should take the following form::

     { <storage-engine-name>: <options> }

  Storage engine configurations specified when creating collections are
  validated and logged to the :term:`oplog` during replication to support
  replica sets with members that use different storage engines.
interface: phpmethod
130
operation: ~
131 132
optional: true
---
133
source:
134
  file: apiargs-MongoDBDatabase-common-option.yaml
135
  ref: typeMap
136 137
post: |
  This will be used for the returned command result document.
138 139 140 141 142 143
---
arg_name: option
name: validator
type: array
description: |
  Allows users to specify :manual:`validation rules or expressions
144 145 146
  </core/document-validation>` for the collection. For more information, see
  :manual:`Document Validation </core/document-validation>` in the MongoDB
  manual.
147

148 149 150 151 152
  The ``validator`` option takes an array that specifies the validation rules or
  expressions. You can specify the expressions using the same operators as
  MongoDB's :manual:`query operators </reference/operator/query>` with the
  exception of :query:`$geoNear`, :query:`$near`, :query:`$nearSphere`,
  :query:`$text`, and :query:`$where`.
153 154 155

  .. note::

156 157
     - Validation occurs during updates and inserts. Existing documents do not
       undergo validation checks until modification.
158 159 160 161 162

     - You cannot specify a validator for collections in the ``admin``,
       ``local``, and ``config`` databases.

     - You cannot specify a validator for ``system.*`` collections.
163
operation: ~
164 165 166 167
interface: phpmethod
optional: true
---
arg_name: option
168
name: validationAction
169 170
type: string
description: |
171 172 173 174 175 176 177
   Determines whether to ``error`` on invalid documents or just ``warn`` about
   the violations but allow invalid documents to be inserted.

   .. important::

      Validation of documents only applies to those documents as determined by
      the ``validationLevel``.
178 179 180 181

   .. list-table::
      :header-rows: 1

182
      * - ``validationAction``
183 184 185

        - Description

186
      * - ``"error"``
187

188 189
        - **Default**. Documents must pass validation before the write occurs.
          Otherwise, the write operation fails.
190

191
      * - ``"warn"``
192

193 194
        - Documents do not have to pass validation. If the document fails
          validation, the write operation logs the validation failure.
195
interface: phpmethod
196
operation: ~
197 198 199
optional: true
---
arg_name: option
200
name: validationLevel
201 202
type: string
description: |
203 204
   Determines how strictly MongoDB applies the validation rules to existing
   documents during an update.
205 206 207 208

   .. list-table::
      :header-rows: 1

209
      * - ``validationLevel``
210 211 212

        - Description

213
      * - ``"off"``
214

215
        - No validation for inserts or updates.
216

217
      * - ``"strict"``
218

219 220 221 222 223 224 225
        - **Default**. Apply validation rules to all inserts and all updates.

      * - ``"moderate"``

        - Apply validation rules to inserts and to updates on existing *valid*
          documents. Do not apply rules to updates on existing *invalid*
          documents.
226
interface: phpmethod
227
operation: ~
228
optional: true
229 230 231 232 233 234 235
---
source:
  file: apiargs-MongoDBDatabase-common-option.yaml
  ref: writeConcern
post: |
  This is not supported for server versions prior to 3.4 and will result in an
  exception at execution time if used.
236
...