/* Copyright 2010-present MongoDB Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
using MongoDB.Bson;
using MongoDB.Bson.Serialization;
using MongoDB.Driver.Search;
namespace MongoDB.Driver
{
internal interface IMongoCollection
{
CollectionNamespace CollectionNamespace { get; }
IBsonSerializer DocumentSerializer { get; }
}
///
/// Represents a typed collection in MongoDB.
///
///
/// This interface is not guaranteed to remain stable. Implementors should use
/// .
///
/// The type of the documents stored in the collection.
public interface IMongoCollection // TODO: derive from IMongoCollection in 4.0
{
///
/// Gets the namespace of the collection.
///
CollectionNamespace CollectionNamespace { get; }
///
/// Gets the database.
///
IMongoDatabase Database { get; }
///
/// Gets the document serializer.
///
IBsonSerializer DocumentSerializer { get; }
///
/// Gets the index manager.
///
IMongoIndexManager Indexes { get; }
///
/// Gets the search index manager.
///
IMongoSearchIndexManager SearchIndexes { get; }
///
/// Gets the settings.
///
MongoCollectionSettings Settings { get; }
///
/// Runs an aggregation pipeline.
///
/// The type of the result.
/// The pipeline.
/// The options.
/// The cancellation token.
/// A cursor.
IAsyncCursor Aggregate(PipelineDefinition pipeline, AggregateOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Runs an aggregation pipeline.
///
/// The type of the result.
/// The session.
/// The pipeline.
/// The options.
/// The cancellation token.
///
/// A cursor.
///
IAsyncCursor Aggregate(IClientSessionHandle session, PipelineDefinition pipeline, AggregateOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Runs an aggregation pipeline.
///
/// The type of the result.
/// The pipeline.
/// The options.
/// The cancellation token.
/// A Task whose result is a cursor.
Task> AggregateAsync(PipelineDefinition pipeline, AggregateOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Runs an aggregation pipeline.
///
/// The type of the result.
/// The session.
/// The pipeline.
/// The options.
/// The cancellation token.
///
/// A Task whose result is a cursor.
///
Task> AggregateAsync(IClientSessionHandle session, PipelineDefinition pipeline, AggregateOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Runs an aggregation pipeline whose results are written to a collection.
///
/// The type of the result.
/// The pipeline.
/// The options.
/// The cancellation token.
void AggregateToCollection(PipelineDefinition pipeline, AggregateOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Runs an aggregation pipeline whose results are written to a collection.
///
/// The type of the result.
/// The session.
/// The pipeline.
/// The options.
/// The cancellation token.
void AggregateToCollection(IClientSessionHandle session, PipelineDefinition pipeline, AggregateOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Runs an aggregation pipeline whose results are written to a collection.
///
/// The type of the result.
/// The pipeline.
/// The options.
/// The cancellation token.
/// A Task.
Task AggregateToCollectionAsync(PipelineDefinition pipeline, AggregateOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Runs an aggregation pipeline whose results are written to a collection.
///
/// The type of the result.
/// The session.
/// The pipeline.
/// The options.
/// The cancellation token.
/// A Task.
Task AggregateToCollectionAsync(IClientSessionHandle session, PipelineDefinition pipeline, AggregateOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Performs multiple write operations.
///
/// The requests.
/// The options.
/// The cancellation token.
/// The result of writing.
BulkWriteResult BulkWrite(IEnumerable> requests, BulkWriteOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Performs multiple write operations.
///
/// The session.
/// The requests.
/// The options.
/// The cancellation token.
///
/// The result of writing.
///
BulkWriteResult BulkWrite(IClientSessionHandle session, IEnumerable> requests, BulkWriteOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Performs multiple write operations.
///
/// The requests.
/// The options.
/// The cancellation token.
/// The result of writing.
Task> BulkWriteAsync(IEnumerable> requests, BulkWriteOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Performs multiple write operations.
///
/// The session.
/// The requests.
/// The options.
/// The cancellation token.
///
/// The result of writing.
///
Task> BulkWriteAsync(IClientSessionHandle session, IEnumerable> requests, BulkWriteOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Counts the number of documents in the collection.
///
/// The filter.
/// The options.
/// The cancellation token.
///
/// The number of documents in the collection.
///
[Obsolete("Use CountDocuments or EstimatedDocumentCount instead.")]
long Count(FilterDefinition filter, CountOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Counts the number of documents in the collection.
///
/// The session.
/// The filter.
/// The options.
/// The cancellation token.
///
/// The number of documents in the collection.
///
[Obsolete("Use CountDocuments or EstimatedDocumentCount instead.")]
long Count(IClientSessionHandle session, FilterDefinition filter, CountOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Counts the number of documents in the collection.
///
/// The filter.
/// The options.
/// The cancellation token.
///
/// The number of documents in the collection.
///
[Obsolete("Use CountDocumentsAsync or EstimatedDocumentCountAsync instead.")]
Task CountAsync(FilterDefinition filter, CountOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Counts the number of documents in the collection.
///
/// The session.
/// The filter.
/// The options.
/// The cancellation token.
///
/// The number of documents in the collection.
///
[Obsolete("Use CountDocumentsAsync or EstimatedDocumentCountAsync instead.")]
Task CountAsync(IClientSessionHandle session, FilterDefinition filter, CountOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Counts the number of documents in the collection.
/// For a fast estimate of the total documents in a collection see .
///
///
/// Note: when migrating from Count to CountDocuments the following query operations must be replaced:
///
///
/// +-------------+--------------------------------+
/// | Operator | Replacement |
/// +=============+================================+
/// | $where | $expr |
/// +-------------+--------------------------------+
/// | $near | $geoWithin with $center |
/// +-------------+--------------------------------+
/// | $nearSphere | $geoWithin with $centerSphere |
/// +-------------+--------------------------------+
///
///
/// The filter.
/// The options.
/// The cancellation token.
///
/// The number of documents in the collection.
///
long CountDocuments(FilterDefinition filter, CountOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Counts the number of documents in the collection.
/// For a fast estimate of the total documents in a collection see .
///
///
/// Note: when migrating from Count to CountDocuments the following query operations must be replaced:
///
///
/// +-------------+--------------------------------+
/// | Operator | Replacement |
/// +=============+================================+
/// | $where | $expr |
/// +-------------+--------------------------------+
/// | $near | $geoWithin with $center |
/// +-------------+--------------------------------+
/// | $nearSphere | $geoWithin with $centerSphere |
/// +-------------+--------------------------------+
///
///
/// The session.
/// The filter.
/// The options.
/// The cancellation token.
///
/// The number of documents in the collection.
///
long CountDocuments(IClientSessionHandle session, FilterDefinition filter, CountOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Counts the number of documents in the collection.
/// For a fast estimate of the total documents in a collection see .
///
///
/// Note: when migrating from CountAsync to CountDocumentsAsync the following query operations must be replaced:
///
///
/// +-------------+--------------------------------+
/// | Operator | Replacement |
/// +=============+================================+
/// | $where | $expr |
/// +-------------+--------------------------------+
/// | $near | $geoWithin with $center |
/// +-------------+--------------------------------+
/// | $nearSphere | $geoWithin with $centerSphere |
/// +-------------+--------------------------------+
///
///
/// The filter.
/// The options.
/// The cancellation token.
///
/// The number of documents in the collection.
///
Task CountDocumentsAsync(FilterDefinition filter, CountOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Counts the number of documents in the collection.
/// For a fast estimate of the total documents in a collection see .
///
///
/// Note: when migrating from CountAsync to CountDocumentsAsync the following query operations must be replaced:
///
///
/// +-------------+--------------------------------+
/// | Operator | Replacement |
/// +=============+================================+
/// | $where | $expr |
/// +-------------+--------------------------------+
/// | $near | $geoWithin with $center |
/// +-------------+--------------------------------+
/// | $nearSphere | $geoWithin with $centerSphere |
/// +-------------+--------------------------------+
///
///
/// The session.
/// The filter.
/// The options.
/// The cancellation token.
///
/// The number of documents in the collection.
///
Task CountDocumentsAsync(IClientSessionHandle session, FilterDefinition filter, CountOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Deletes multiple documents.
///
/// The filter.
/// The cancellation token.
///
/// The result of the delete operation.
///
DeleteResult DeleteMany(FilterDefinition filter, CancellationToken cancellationToken = default(CancellationToken));
///
/// Deletes multiple documents.
///
/// The filter.
/// The options.
/// The cancellation token.
///
/// The result of the delete operation.
///
DeleteResult DeleteMany(FilterDefinition filter, DeleteOptions options, CancellationToken cancellationToken = default(CancellationToken));
///
/// Deletes multiple documents.
///
/// The session.
/// The filter.
/// The options.
/// The cancellation token.
///
/// The result of the delete operation.
///
DeleteResult DeleteMany(IClientSessionHandle session, FilterDefinition filter, DeleteOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Deletes multiple documents.
///
/// The filter.
/// The cancellation token.
///
/// The result of the delete operation.
///
Task DeleteManyAsync(FilterDefinition filter, CancellationToken cancellationToken = default(CancellationToken));
///
/// Deletes multiple documents.
///
/// The filter.
/// The options.
/// The cancellation token.
///
/// The result of the delete operation.
///
Task DeleteManyAsync(FilterDefinition filter, DeleteOptions options, CancellationToken cancellationToken = default(CancellationToken));
///
/// Deletes multiple documents.
///
/// The session.
/// The filter.
/// The options.
/// The cancellation token.
///
/// The result of the delete operation.
///
Task DeleteManyAsync(IClientSessionHandle session, FilterDefinition filter, DeleteOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Deletes a single document.
///
/// The filter.
/// The cancellation token.
///
/// The result of the delete operation.
///
DeleteResult DeleteOne(FilterDefinition filter, CancellationToken cancellationToken = default(CancellationToken));
///
/// Deletes a single document.
///
/// The filter.
/// The options.
/// The cancellation token.
///
/// The result of the delete operation.
///
DeleteResult DeleteOne(FilterDefinition filter, DeleteOptions options, CancellationToken cancellationToken = default(CancellationToken));
///
/// Deletes a single document.
///
/// The session.
/// The filter.
/// The options.
/// The cancellation token.
///
/// The result of the delete operation.
///
DeleteResult DeleteOne(IClientSessionHandle session, FilterDefinition filter, DeleteOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Deletes a single document.
///
/// The filter.
/// The cancellation token.
///
/// The result of the delete operation.
///
Task DeleteOneAsync(FilterDefinition filter, CancellationToken cancellationToken = default(CancellationToken));
///
/// Deletes a single document.
///
/// The filter.
/// The options.
/// The cancellation token.
///
/// The result of the delete operation.
///
Task DeleteOneAsync(FilterDefinition filter, DeleteOptions options, CancellationToken cancellationToken = default(CancellationToken));
///
/// Deletes a single document.
///
/// The session.
/// The filter.
/// The options.
/// The cancellation token.
///
/// The result of the delete operation.
///
Task DeleteOneAsync(IClientSessionHandle session, FilterDefinition filter, DeleteOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Gets the distinct values for a specified field.
///
/// The type of the result.
/// The field.
/// The filter.
/// The options.
/// The cancellation token.
/// A cursor.
IAsyncCursor Distinct(FieldDefinition field, FilterDefinition filter, DistinctOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Gets the distinct values for a specified field.
///
/// The type of the result.
/// The session.
/// The field.
/// The filter.
/// The options.
/// The cancellation token.
///
/// A cursor.
///
IAsyncCursor Distinct(IClientSessionHandle session, FieldDefinition field, FilterDefinition filter, DistinctOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Gets the distinct values for a specified field.
///
/// The type of the result.
/// The field.
/// The filter.
/// The options.
/// The cancellation token.
/// A Task whose result is a cursor.
Task> DistinctAsync(FieldDefinition field, FilterDefinition filter, DistinctOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Gets the distinct values for a specified field.
///
/// The type of the result.
/// The session.
/// The field.
/// The filter.
/// The options.
/// The cancellation token.
///
/// A Task whose result is a cursor.
///
Task> DistinctAsync(IClientSessionHandle session, FieldDefinition field, FilterDefinition filter, DistinctOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Gets the distinct values for a specified array field.
///
/// The type of the array items.
/// The field.
/// The filter.
/// The options.
/// The cancellation token.
/// A cursor.
IAsyncCursor DistinctMany(FieldDefinition> field, FilterDefinition filter, DistinctOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Gets the distinct values for a specified array field.
///
/// The type of the array items.
/// The session.
/// The field.
/// The filter.
/// The options.
/// The cancellation token.
/// A cursor.
IAsyncCursor DistinctMany(IClientSessionHandle session, FieldDefinition> field, FilterDefinition filter, DistinctOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Gets the distinct values for a specified array field.
///
/// The type of the array items.
/// The field.
/// The filter.
/// The options.
/// The cancellation token.
/// A cursor.
Task> DistinctManyAsync(FieldDefinition> field, FilterDefinition filter, DistinctOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Gets the distinct values for a specified array field.
///
/// The type of the array items.
/// The session.
/// The field.
/// The filter.
/// The options.
/// The cancellation token.
/// A cursor.
Task> DistinctManyAsync(IClientSessionHandle session, FieldDefinition> field, FilterDefinition filter, DistinctOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Returns an estimate of the number of documents in the collection.
///
/// The options.
/// The cancellation token.
///
/// An estimate of the number of documents in the collection.
///
///
/// Due to an oversight in versions 5.0.0-5.0.8 of MongoDB, the count command, which estimatedDocumentCount uses
/// in its implementation, was not included in v1 of the Stable API. If you are using the Stable API with
/// estimatedDocumentCount, you must upgrade to server version 5.0.9+ or set strict: false when configuring
/// ServerApi to avoid encountering errors.
///
long EstimatedDocumentCount(EstimatedDocumentCountOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Returns an estimate of the number of documents in the collection.
///
/// The options.
/// The cancellation token.
///
/// An estimate of the number of documents in the collection.
///
Task EstimatedDocumentCountAsync(EstimatedDocumentCountOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Finds the documents matching the filter.
///
/// The type of the projection (same as TDocument if there is no projection).
/// The filter.
/// The options.
/// The cancellation token.
/// A cursor.
IAsyncCursor FindSync(FilterDefinition filter, FindOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Finds the documents matching the filter.
///
/// The type of the projection (same as TDocument if there is no projection).
/// The session.
/// The filter.
/// The options.
/// The cancellation token.
///
/// A cursor.
///
IAsyncCursor FindSync(IClientSessionHandle session, FilterDefinition filter, FindOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Finds the documents matching the filter.
///
/// The type of the projection (same as TDocument if there is no projection).
/// The filter.
/// The options.
/// The cancellation token.
/// A Task whose result is a cursor.
Task> FindAsync(FilterDefinition filter, FindOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Finds the documents matching the filter.
///
/// The type of the projection (same as TDocument if there is no projection).
/// The session.
/// The filter.
/// The options.
/// The cancellation token.
///
/// A Task whose result is a cursor.
///
Task> FindAsync(IClientSessionHandle session, FilterDefinition filter, FindOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Finds a single document and deletes it atomically.
///
/// The type of the projection (same as TDocument if there is no projection).
/// The filter.
/// The options.
/// The cancellation token.
///
/// The returned document.
///
TProjection FindOneAndDelete(FilterDefinition filter, FindOneAndDeleteOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Finds a single document and deletes it atomically.
///
/// The type of the projection (same as TDocument if there is no projection).
/// The session.
/// The filter.
/// The options.
/// The cancellation token.
///
/// The returned document.
///
TProjection FindOneAndDelete(IClientSessionHandle session, FilterDefinition filter, FindOneAndDeleteOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Finds a single document and deletes it atomically.
///
/// The type of the projection (same as TDocument if there is no projection).
/// The filter.
/// The options.
/// The cancellation token.
///
/// The returned document.
///
Task FindOneAndDeleteAsync(FilterDefinition filter, FindOneAndDeleteOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Finds a single document and deletes it atomically.
///
/// The type of the projection (same as TDocument if there is no projection).
/// The session.
/// The filter.
/// The options.
/// The cancellation token.
///
/// The returned document.
///
Task FindOneAndDeleteAsync(IClientSessionHandle session, FilterDefinition filter, FindOneAndDeleteOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Finds a single document and replaces it atomically.
///
/// The type of the projection (same as TDocument if there is no projection).
/// The filter.
/// The replacement.
/// The options.
/// The cancellation token.
///
/// The returned document.
///
TProjection FindOneAndReplace(FilterDefinition filter, TDocument replacement, FindOneAndReplaceOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Finds a single document and replaces it atomically.
///
/// The type of the projection (same as TDocument if there is no projection).
/// The session.
/// The filter.
/// The replacement.
/// The options.
/// The cancellation token.
///
/// The returned document.
///
TProjection FindOneAndReplace(IClientSessionHandle session, FilterDefinition filter, TDocument replacement, FindOneAndReplaceOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Finds a single document and replaces it atomically.
///
/// The type of the projection (same as TDocument if there is no projection).
/// The filter.
/// The replacement.
/// The options.
/// The cancellation token.
///
/// The returned document.
///
Task FindOneAndReplaceAsync(FilterDefinition filter, TDocument replacement, FindOneAndReplaceOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Finds a single document and replaces it atomically.
///
/// The type of the projection (same as TDocument if there is no projection).
/// The session.
/// The filter.
/// The replacement.
/// The options.
/// The cancellation token.
///
/// The returned document.
///
Task FindOneAndReplaceAsync(IClientSessionHandle session, FilterDefinition filter, TDocument replacement, FindOneAndReplaceOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Finds a single document and updates it atomically.
///
/// The type of the projection (same as TDocument if there is no projection).
/// The filter.
/// The update.
/// The options.
/// The cancellation token.
///
/// The returned document.
///
TProjection FindOneAndUpdate(FilterDefinition filter, UpdateDefinition update, FindOneAndUpdateOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Finds a single document and updates it atomically.
///
/// The type of the projection (same as TDocument if there is no projection).
/// The session.
/// The filter.
/// The update.
/// The options.
/// The cancellation token.
///
/// The returned document.
///
TProjection FindOneAndUpdate(IClientSessionHandle session, FilterDefinition filter, UpdateDefinition update, FindOneAndUpdateOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Finds a single document and updates it atomically.
///
/// The type of the projection (same as TDocument if there is no projection).
/// The filter.
/// The update.
/// The options.
/// The cancellation token.
///
/// The returned document.
///
Task FindOneAndUpdateAsync(FilterDefinition filter, UpdateDefinition update, FindOneAndUpdateOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Finds a single document and updates it atomically.
///
/// The type of the projection (same as TDocument if there is no projection).
/// The session.
/// The filter.
/// The update.
/// The options.
/// The cancellation token.
///
/// The returned document.
///
Task FindOneAndUpdateAsync(IClientSessionHandle session, FilterDefinition filter, UpdateDefinition update, FindOneAndUpdateOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Inserts a single document.
///
/// The document.
/// The options.
/// The cancellation token.
void InsertOne(TDocument document, InsertOneOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Inserts a single document.
///
/// The session.
/// The document.
/// The options.
/// The cancellation token.
void InsertOne(IClientSessionHandle session, TDocument document, InsertOneOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Inserts a single document.
///
/// The document.
/// The cancellation token.
///
/// The result of the insert operation.
///
[Obsolete("Use the new overload of InsertOneAsync with an InsertOneOptions parameter instead.")]
Task InsertOneAsync(TDocument document, CancellationToken _cancellationToken);
///
/// Inserts a single document.
///
/// The document.
/// The options.
/// The cancellation token.
///
/// The result of the insert operation.
///
Task InsertOneAsync(TDocument document, InsertOneOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Inserts a single document.
///
/// The session.
/// The document.
/// The options.
/// The cancellation token.
///
/// The result of the insert operation.
///
Task InsertOneAsync(IClientSessionHandle session, TDocument document, InsertOneOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Inserts many documents.
///
/// The documents.
/// The options.
/// The cancellation token.
void InsertMany(IEnumerable documents, InsertManyOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Inserts many documents.
///
/// The session.
/// The documents.
/// The options.
/// The cancellation token.
void InsertMany(IClientSessionHandle session, IEnumerable documents, InsertManyOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Inserts many documents.
///
/// The documents.
/// The options.
/// The cancellation token.
///
/// The result of the insert operation.
///
Task InsertManyAsync(IEnumerable documents, InsertManyOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Inserts many documents.
///
/// The session.
/// The documents.
/// The options.
/// The cancellation token.
///
/// The result of the insert operation.
///
Task InsertManyAsync(IClientSessionHandle session, IEnumerable documents, InsertManyOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Executes a map-reduce command.
///
/// The type of the result.
/// The map function.
/// The reduce function.
/// The options.
/// The cancellation token.
/// A cursor.
[Obsolete("Use Aggregation pipeline instead.")]
IAsyncCursor MapReduce(BsonJavaScript map, BsonJavaScript reduce, MapReduceOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Executes a map-reduce command.
///
/// The type of the result.
/// The session.
/// The map function.
/// The reduce function.
/// The options.
/// The cancellation token.
///
/// A cursor.
///
[Obsolete("Use Aggregation pipeline instead.")]
IAsyncCursor MapReduce(IClientSessionHandle session, BsonJavaScript map, BsonJavaScript reduce, MapReduceOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Executes a map-reduce command.
///
/// The type of the result.
/// The map function.
/// The reduce function.
/// The options.
/// The cancellation token.
/// A Task whose result is a cursor.
[Obsolete("Use Aggregation pipeline instead.")]
Task> MapReduceAsync(BsonJavaScript map, BsonJavaScript reduce, MapReduceOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Executes a map-reduce command.
///
/// The type of the result.
/// The session.
/// The map function.
/// The reduce function.
/// The options.
/// The cancellation token.
///
/// A Task whose result is a cursor.
///
[Obsolete("Use Aggregation pipeline instead.")]
Task> MapReduceAsync(IClientSessionHandle session, BsonJavaScript map, BsonJavaScript reduce, MapReduceOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Returns a filtered collection that appears to contain only documents of the derived type.
/// All operations using this filtered collection will automatically use discriminators as necessary.
///
/// The type of the derived document.
/// A filtered collection.
IFilteredMongoCollection OfType() where TDerivedDocument : TDocument;
///
/// Replaces a single document.
///
/// The filter.
/// The replacement.
/// The options.
/// The cancellation token.
///
/// The result of the replacement.
///
ReplaceOneResult ReplaceOne(FilterDefinition filter, TDocument replacement, ReplaceOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Replaces a single document.
///
/// The filter.
/// The replacement.
/// The options.
/// The cancellation token.
///
/// The result of the replacement.
///
[Obsolete("Use the overload that takes a ReplaceOptions instead of an UpdateOptions.")]
ReplaceOneResult ReplaceOne(FilterDefinition filter, TDocument replacement, UpdateOptions options, CancellationToken cancellationToken = default(CancellationToken));
///
/// Replaces a single document.
///
/// The session.
/// The filter.
/// The replacement.
/// The options.
/// The cancellation token.
///
/// The result of the replacement.
///
ReplaceOneResult ReplaceOne(IClientSessionHandle session, FilterDefinition filter, TDocument replacement, ReplaceOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Replaces a single document.
///
/// The session.
/// The filter.
/// The replacement.
/// The options.
/// The cancellation token.
///
/// The result of the replacement.
///
[Obsolete("Use the overload that takes a ReplaceOptions instead of an UpdateOptions.")]
ReplaceOneResult ReplaceOne(IClientSessionHandle session, FilterDefinition filter, TDocument replacement, UpdateOptions options, CancellationToken cancellationToken = default(CancellationToken));
///
/// Replaces a single document.
///
/// The filter.
/// The replacement.
/// The options.
/// The cancellation token.
///
/// The result of the replacement.
///
Task ReplaceOneAsync(FilterDefinition filter, TDocument replacement, ReplaceOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Replaces a single document.
///
/// The filter.
/// The replacement.
/// The options.
/// The cancellation token.
///
/// The result of the replacement.
///
[Obsolete("Use the overload that takes a ReplaceOptions instead of an UpdateOptions.")]
Task ReplaceOneAsync(FilterDefinition filter, TDocument replacement, UpdateOptions options, CancellationToken cancellationToken = default(CancellationToken));
///
/// Replaces a single document.
///
/// The session.
/// The filter.
/// The replacement.
/// The options.
/// The cancellation token.
///
/// The result of the replacement.
///
Task ReplaceOneAsync(IClientSessionHandle session, FilterDefinition filter, TDocument replacement, ReplaceOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Replaces a single document.
///
/// The session.
/// The filter.
/// The replacement.
/// The options.
/// The cancellation token.
///
/// The result of the replacement.
///
[Obsolete("Use the overload that takes a ReplaceOptions instead of an UpdateOptions.")]
Task ReplaceOneAsync(IClientSessionHandle session, FilterDefinition filter, TDocument replacement, UpdateOptions options, CancellationToken cancellationToken = default(CancellationToken));
///
/// Updates many documents.
///
/// The filter.
/// The update.
/// The options.
/// The cancellation token.
///
/// The result of the update operation.
///
UpdateResult UpdateMany(FilterDefinition filter, UpdateDefinition update, UpdateOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Updates many documents.
///
/// The session.
/// The filter.
/// The update.
/// The options.
/// The cancellation token.
///
/// The result of the update operation.
///
UpdateResult UpdateMany(IClientSessionHandle session, FilterDefinition filter, UpdateDefinition update, UpdateOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Updates many documents.
///
/// The filter.
/// The update.
/// The options.
/// The cancellation token.
///
/// The result of the update operation.
///
Task UpdateManyAsync(FilterDefinition filter, UpdateDefinition update, UpdateOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Updates many documents.
///
/// The session.
/// The filter.
/// The update.
/// The options.
/// The cancellation token.
///
/// The result of the update operation.
///
Task UpdateManyAsync(IClientSessionHandle session, FilterDefinition filter, UpdateDefinition update, UpdateOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Updates a single document.
///
/// The filter.
/// The update.
/// The options.
/// The cancellation token.
///
/// The result of the update operation.
///
UpdateResult UpdateOne(FilterDefinition filter, UpdateDefinition update, UpdateOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Updates a single document.
///
/// The session.
/// The filter.
/// The update.
/// The options.
/// The cancellation token.
///
/// The result of the update operation.
///
UpdateResult UpdateOne(IClientSessionHandle session, FilterDefinition filter, UpdateDefinition update, UpdateOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Updates a single document.
///
/// The filter.
/// The update.
/// The options.
/// The cancellation token.
///
/// The result of the update operation.
///
Task UpdateOneAsync(FilterDefinition filter, UpdateDefinition update, UpdateOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Updates a single document.
///
/// The session.
/// The filter.
/// The update.
/// The options.
/// The cancellation token.
///
/// The result of the update operation.
///
Task UpdateOneAsync(IClientSessionHandle session, FilterDefinition filter, UpdateDefinition update, UpdateOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Watches changes on the collection.
///
/// The type of the result.
/// The pipeline.
/// The options.
/// The cancellation token.
///
/// A change stream.
///
IChangeStreamCursor Watch(
PipelineDefinition, TResult> pipeline,
ChangeStreamOptions options = null,
CancellationToken cancellationToken = default(CancellationToken));
///
/// Watches changes on the collection.
///
/// The type of the result.
/// The session.
/// The pipeline.
/// The options.
/// The cancellation token.
///
/// A change stream.
///
IChangeStreamCursor Watch(
IClientSessionHandle session,
PipelineDefinition, TResult> pipeline,
ChangeStreamOptions options = null,
CancellationToken cancellationToken = default(CancellationToken));
///
/// Watches changes on the collection.
///
/// The type of the result.
/// The pipeline.
/// The options.
/// The cancellation token.
///
/// A change stream.
///
Task> WatchAsync(
PipelineDefinition, TResult> pipeline,
ChangeStreamOptions options = null,
CancellationToken cancellationToken = default(CancellationToken));
///
/// Watches changes on the collection.
///
/// The type of the result.
/// The session.
/// The pipeline.
/// The options.
/// The cancellation token.
///
/// A change stream.
///
Task> WatchAsync(
IClientSessionHandle session,
PipelineDefinition, TResult> pipeline,
ChangeStreamOptions options = null,
CancellationToken cancellationToken = default(CancellationToken));
///
/// Returns a new IMongoCollection instance with a different read concern setting.
///
/// The read concern.
/// A new IMongoCollection instance with a different read concern setting.
IMongoCollection WithReadConcern(ReadConcern readConcern);
///
/// Returns a new IMongoCollection instance with a different read preference setting.
///
/// The read preference.
/// A new IMongoCollection instance with a different read preference setting.
IMongoCollection WithReadPreference(ReadPreference readPreference);
///
/// Returns a new IMongoCollection instance with a different write concern setting.
///
/// The write concern.
/// A new IMongoCollection instance with a different write concern setting.
IMongoCollection WithWriteConcern(WriteConcern writeConcern);
}
}