Table of Contents

Method CreateOneAsync

Namespace
MongoDB.Driver
Assembly
MongoDB.Driver.dll

CreateOneAsync(IndexKeysDefinition<TDocument>, CreateIndexOptions, CancellationToken)

Creates an index.

[Obsolete("Use CreateOneAsync with a CreateIndexModel instead.")]
public virtual Task<string> CreateOneAsync(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

Task<string>

A task whose result is the name of the index that was created.

CreateOneAsync(CreateIndexModel<TDocument>, CreateOneIndexOptions, CancellationToken)

Creates an index.

public virtual Task<string> CreateOneAsync(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

Task<string>

A task whose result is the name of the index that was created.

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

Creates an index.

[Obsolete("Use CreateOneAsync with a CreateIndexModel instead.")]
public virtual Task<string> CreateOneAsync(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

Task<string>

A task whose result is the name of the index that was created.

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

Creates an index.

public virtual Task<string> CreateOneAsync(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

Task<string>

A task whose result is the name of the index that was created.