Table of Contents

Method CreateOne

Namespace
MongoDB.Driver
Assembly
MongoDB.Driver.dll

CreateOne(IndexKeysDefinition<TDocument>, CreateIndexOptions, CancellationToken)

Creates an index.

[Obsolete("Use CreateOne with a CreateIndexModel instead.")]
public virtual string CreateOne(IndexKeysDefinition<TDocument> keys, CreateIndexOptions options = null, CancellationToken cancellationToken = default)

Parameters

keys IndexKeysDefinition<TDocument>

The keys.

options CreateIndexOptions

The create index request options.

cancellationToken CancellationToken

The cancellation token.

Returns

string

The name of the index that was created.

CreateOne(CreateIndexModel<TDocument>, CreateOneIndexOptions, CancellationToken)

Creates an index.

public virtual string CreateOne(CreateIndexModel<TDocument> model, CreateOneIndexOptions options = null, CancellationToken cancellationToken = default)

Parameters

model CreateIndexModel<TDocument>

The model defining the index.

options CreateOneIndexOptions

The create index operation options.

cancellationToken CancellationToken

The cancellation token.

Returns

string

The name of the index that was created.

CreateOne(IClientSessionHandle, IndexKeysDefinition<TDocument>, CreateIndexOptions, CancellationToken)

Creates an index.

[Obsolete("Use CreateOne with a CreateIndexModel instead.")]
public virtual string CreateOne(IClientSessionHandle session, IndexKeysDefinition<TDocument> keys, CreateIndexOptions options = null, CancellationToken cancellationToken = default)

Parameters

session IClientSessionHandle

The session.

keys IndexKeysDefinition<TDocument>

The keys.

options CreateIndexOptions

The create index request options.

cancellationToken CancellationToken

The cancellation token.

Returns

string

The name of the index that was created.

CreateOne(IClientSessionHandle, CreateIndexModel<TDocument>, CreateOneIndexOptions, CancellationToken)

Creates an index.

public virtual string CreateOne(IClientSessionHandle session, CreateIndexModel<TDocument> model, CreateOneIndexOptions options = null, CancellationToken cancellationToken = default)

Parameters

session IClientSessionHandle

The session.

model CreateIndexModel<TDocument>

The model defining the index.

options CreateOneIndexOptions

The create index operation options.

cancellationToken CancellationToken

The cancellation token.

Returns

string

The name of the index that was created.