CreateCollection
in package
Operation for the create command.
Tags
Table of Contents
Properties
- $collectionName : string
- $databaseName : string
- $options : array<string|int, mixed>
Methods
- __construct() : mixed
- Constructs a create command.
- execute() : void
- Execute the operation.
- createCommand() : Command
- Create the create command.
- createOptions() : array<string|int, mixed>
- Create options for executing the command.
Properties
$collectionName
private
string
$collectionName
$databaseName
private
string
$databaseName
$options
private
array<string|int, mixed>
$options
= []
Methods
__construct()
Constructs a create command.
public
__construct(string $databaseName, string $collectionName[, array<string|int, mixed> $options = [] ]) : mixed
Supported options:
-
capped (boolean): Specify true to create a capped collection. If set, the size option must also be specified. The default is false.
-
comment (mixed): BSON value to attach as a comment to this command.
This is not supported for servers versions < 4.4.
-
changeStreamPreAndPostImages (document): Used to configure support for pre- and post-images in change streams.
This is not supported for server versions < 6.0.
-
clusteredIndex (document): A clustered index specification.
This is not supported for server versions < 5.3.
-
collation (document): Collation specification.
-
encryptedFields (document): Configuration for encrypted fields. See: https://www.mongodb.com/docs/manual/core/queryable-encryption/fundamentals/encrypt-and-query/
-
expireAfterSeconds: The TTL for documents in time series collections.
This is not supported for servers versions < 5.0.
-
indexOptionDefaults (document): Default configuration for indexes when creating the collection.
-
max (integer): The maximum number of documents allowed in the capped collection. The size option takes precedence over this limit.
-
maxTimeMS (integer): The maximum amount of time to allow the query to run.
-
pipeline (array): An array that consists of the aggregation pipeline stage(s), which will be applied to the collection or view specified by viewOn.
-
session (MongoDB\Driver\Session): Client session.
-
size (integer): The maximum number of bytes for a capped collection.
-
storageEngine (document): Storage engine options.
-
timeseries (document): Options for time series collections.
This is not supported for servers versions < 5.0.
-
validationAction (string): Validation action.
-
validationLevel (string): Validation level.
-
validator (document): Validation rules or expressions.
-
viewOn (string): The name of the source collection or view from which to create the view.
-
writeConcern (MongoDB\Driver\WriteConcern): Write concern.
Parameters
- $databaseName : string
-
Database name
- $collectionName : string
-
Collection name
- $options : array<string|int, mixed> = []
-
Command options
Tags
execute()
Execute the operation.
public
execute(Server $server) : void
Parameters
- $server : Server
Tags
createCommand()
Create the create command.
private
createCommand() : Command
Return values
CommandcreateOptions()
Create options for executing the command.
private
createOptions() : array<string|int, mixed>