Table of Contents

Class CreateCollectionOperation

Namespace
MongoDB.Driver.Core.Operations
Assembly
MongoDB.Driver.Core.dll

Represents a create collection operation.

public class CreateCollectionOperation : IWriteOperation<BsonDocument>
Inheritance
CreateCollectionOperation
Implements
Inherited Members
Extension Methods

Constructors

CreateCollectionOperation(CollectionNamespace, MessageEncoderSettings)

Initializes a new instance of the CreateCollectionOperation class.

public CreateCollectionOperation(CollectionNamespace collectionNamespace, MessageEncoderSettings messageEncoderSettings)

Parameters

collectionNamespace CollectionNamespace

The collection namespace.

messageEncoderSettings MessageEncoderSettings

The message encoder settings.

Properties

AutoIndexId

Gets or sets a value indicating whether an index on _id should be created automatically.

[Obsolete("AutoIndexId has been deprecated since server version 3.2.")]
public bool? AutoIndexId { get; set; }

Property Value

bool?

A value indicating whether an index on _id should be created automatically.

Capped

Gets or sets a value indicating whether the collection is a capped collection.

public bool? Capped { get; set; }

Property Value

bool?

A value indicating whether the collection is a capped collection.

ChangeStreamPreAndPostImages

Gets or sets a change streams pre and post images options.

public BsonDocument ChangeStreamPreAndPostImages { get; set; }

Property Value

BsonDocument

change streams pre and post images options.

ClusteredIndex

Gets or sets the clustered index definition.

public BsonDocument ClusteredIndex { get; set; }

Property Value

BsonDocument

The clustered index definition.

Collation

Gets or sets the collation.

public Collation Collation { get; set; }

Property Value

Collation

The collation.

CollectionNamespace

Gets the collection namespace.

public CollectionNamespace CollectionNamespace { get; }

Property Value

CollectionNamespace

The collection namespace.

Comment

Gets or sets the comment.

public BsonValue Comment { get; set; }

Property Value

BsonValue

The comment.

ExpireAfter

Gets or sets the expiration timespan for time series collections. Used to automatically delete documents in time series collections. See https://www.mongodb.com/docs/manual/reference/command/create/ for supported options and https://www.mongodb.com/docs/manual/core/timeseries-collections/ for more information on time series collections.

public TimeSpan? ExpireAfter { get; set; }

Property Value

TimeSpan?

The timespan after which to expire documents.

IndexOptionDefaults

Gets or sets the index option defaults.

public BsonDocument IndexOptionDefaults { get; set; }

Property Value

BsonDocument

The index option defaults.

MaxDocuments

Gets or sets the maximum number of documents in a capped collection.

public long? MaxDocuments { get; set; }

Property Value

long?

The maximum number of documents in a capped collection.

MaxSize

Gets or sets the maximum size of a capped collection.

public long? MaxSize { get; set; }

Property Value

long?

The maximum size of a capped collection.

MessageEncoderSettings

Gets the message encoder settings.

public MessageEncoderSettings MessageEncoderSettings { get; }

Property Value

MessageEncoderSettings

The message encoder settings.

NoPadding

Gets or sets whether padding should not be used.

public bool? NoPadding { get; set; }

Property Value

bool?

StorageEngine

Gets or sets the storage engine options.

public BsonDocument StorageEngine { get; set; }

Property Value

BsonDocument

The storage engine options.

TimeSeriesOptions

Gets or sets the TimeSeriesOptions. Represents an object containing options for creating time series collections. See https://www.mongodb.com/docs/manual/reference/command/create/ for supported options and https://www.mongodb.com/docs/manual/core/timeseries-collections/ for more information on time series collections.

public TimeSeriesOptions TimeSeriesOptions { get; set; }

Property Value

TimeSeriesOptions

The time series options.

UsePowerOf2Sizes

Gets or sets a value indicating whether the collection should use power of 2 sizes.

public bool? UsePowerOf2Sizes { get; set; }

Property Value

bool?

A value indicating whether the collection should use power of 2 sizes.

ValidationAction

Gets or sets the validation action.

public DocumentValidationAction? ValidationAction { get; set; }

Property Value

DocumentValidationAction?

The validation action.

ValidationLevel

Gets or sets the validation level.

public DocumentValidationLevel? ValidationLevel { get; set; }

Property Value

DocumentValidationLevel?

The validation level.

Validator

Gets or sets the validator.

public BsonDocument Validator { get; set; }

Property Value

BsonDocument

The validator.

WriteConcern

Gets or sets the write concern.

public WriteConcern WriteConcern { get; set; }

Property Value

WriteConcern

The write concern.

Methods

Execute(IWriteBinding, CancellationToken)

Executes the operation.

public BsonDocument Execute(IWriteBinding binding, CancellationToken cancellationToken)

Parameters

binding IWriteBinding

The binding.

cancellationToken CancellationToken

The cancellation token.

Returns

BsonDocument

The result of the operation.

ExecuteAsync(IWriteBinding, CancellationToken)

Executes the operation.

public Task<BsonDocument> ExecuteAsync(IWriteBinding binding, CancellationToken cancellationToken)

Parameters

binding IWriteBinding

The binding.

cancellationToken CancellationToken

The cancellation token.

Returns

Task<BsonDocument>

A Task whose result is the result of the operation.