/* 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.Threading;
using System.Threading.Tasks;
using MongoDB.Bson;
namespace MongoDB.Driver
{
///
/// Represents a database in MongoDB.
///
public interface IMongoDatabase
{
///
/// Gets the client.
///
IMongoClient Client { get; }
///
/// Gets the namespace of the database.
///
DatabaseNamespace DatabaseNamespace { get; }
///
/// Gets the settings.
///
MongoDatabaseSettings 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.
///
/// 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.
///
/// 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.
///
/// 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.
///
/// 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));
///
/// Creates the collection with the specified name.
///
/// The name.
/// The options.
/// The cancellation token.
void CreateCollection(string name, CreateCollectionOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Creates the collection with the specified name.
///
/// The session.
/// The name.
/// The options.
/// The cancellation token.
void CreateCollection(IClientSessionHandle session, string name, CreateCollectionOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Creates the collection with the specified name.
///
/// The name.
/// The options.
/// The cancellation token.
/// A task.
Task CreateCollectionAsync(string name, CreateCollectionOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Creates the collection with the specified name.
///
/// The session.
/// The name.
/// The options.
/// The cancellation token.
///
/// A task.
///
Task CreateCollectionAsync(IClientSessionHandle session, string name, CreateCollectionOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Creates a view.
///
/// The type of the input documents.
/// The type of the pipeline result documents.
/// The name of the view.
/// The name of the collection that the view is on.
/// The pipeline.
/// The options.
/// The cancellation token.
void CreateView(string viewName, string viewOn, PipelineDefinition pipeline, CreateViewOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Creates a view.
///
/// The type of the input documents.
/// The type of the pipeline result documents.
/// The session.
/// The name of the view.
/// The name of the collection that the view is on.
/// The pipeline.
/// The options.
/// The cancellation token.
void CreateView(IClientSessionHandle session, string viewName, string viewOn, PipelineDefinition pipeline, CreateViewOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Creates a view.
///
/// The type of the input documents.
/// The type of the pipeline result documents.
/// The name of the view.
/// The name of the collection that the view is on.
/// The pipeline.
/// The options.
/// The cancellation token.
/// A task.
Task CreateViewAsync(string viewName, string viewOn, PipelineDefinition pipeline, CreateViewOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Creates a view.
///
/// The type of the input documents.
/// The type of the pipeline result documents.
/// The session.
/// The name of the view.
/// The name of the collection that the view is on.
/// The pipeline.
/// The options.
/// The cancellation token.
///
/// A task.
///
Task CreateViewAsync(IClientSessionHandle session, string viewName, string viewOn, PipelineDefinition pipeline, CreateViewOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Drops the collection with the specified name.
///
/// The name of the collection to drop.
/// The cancellation token.
void DropCollection(string name, CancellationToken cancellationToken = default(CancellationToken));
///
/// Drops the collection with the specified name.
///
/// The name of the collection to drop.
/// The options.
/// The cancellation token.
void DropCollection(string name, DropCollectionOptions options, CancellationToken cancellationToken = default(CancellationToken));
///
/// Drops the collection with the specified name.
///
/// The session.
/// The name of the collection to drop.
/// The cancellation token.
void DropCollection(IClientSessionHandle session, string name, CancellationToken cancellationToken = default(CancellationToken));
///
/// Drops the collection with the specified name.
///
/// The session.
/// The name of the collection to drop.
/// The options.
/// The cancellation token.
void DropCollection(IClientSessionHandle session, string name, DropCollectionOptions options, CancellationToken cancellationToken = default(CancellationToken));
///
/// Drops the collection with the specified name.
///
/// The name of the collection to drop.
/// The cancellation token.
/// A task.
Task DropCollectionAsync(string name, CancellationToken cancellationToken = default(CancellationToken));
///
/// Drops the collection with the specified name.
///
/// The name of the collection to drop.
/// The options.
/// The cancellation token.
/// A task.
Task DropCollectionAsync(string name, DropCollectionOptions options, CancellationToken cancellationToken = default(CancellationToken));
///
/// Drops the collection with the specified name.
///
/// The session.
/// The name of the collection to drop.
/// The cancellation token.
///
/// A task.
///
Task DropCollectionAsync(IClientSessionHandle session, string name, CancellationToken cancellationToken = default(CancellationToken));
///
/// Drops the collection with the specified name.
///
/// The session.
/// The name of the collection to drop.
/// The options.
/// The cancellation token.
///
/// A task.
///
Task DropCollectionAsync(IClientSessionHandle session, string name, DropCollectionOptions options, CancellationToken cancellationToken = default(CancellationToken));
///
/// Gets a collection.
///
/// The document type.
/// The name of the collection.
/// The settings.
/// An implementation of a collection.
IMongoCollection GetCollection(string name, MongoCollectionSettings settings = null);
///
/// Lists the names of all the collections in the database.
///
/// The options.
/// The cancellation token.
/// A cursor.
IAsyncCursor ListCollectionNames(ListCollectionNamesOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Lists the names of all the collections in the database.
///
/// The session.
/// The options.
/// The cancellation token.
/// A cursor.
IAsyncCursor ListCollectionNames(IClientSessionHandle session, ListCollectionNamesOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Lists the names of all the collections in the database.
///
/// The options.
/// The cancellation token.
/// A Task whose result is a cursor.
Task> ListCollectionNamesAsync(ListCollectionNamesOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Lists the names of all the collections in the database.
///
/// The session.
/// The options.
/// The cancellation token.
/// A Task whose result is a cursor.
Task> ListCollectionNamesAsync(IClientSessionHandle session, ListCollectionNamesOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Lists all the collections in the database.
///
/// The options.
/// The cancellation token.
/// A cursor.
IAsyncCursor ListCollections(ListCollectionsOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Lists all the collections in the database.
///
/// The session.
/// The options.
/// The cancellation token.
///
/// A cursor.
///
IAsyncCursor ListCollections(IClientSessionHandle session, ListCollectionsOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Lists all the collections in the database.
///
/// The options.
/// The cancellation token.
/// A Task whose result is a cursor.
Task> ListCollectionsAsync(ListCollectionsOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Lists all the collections in the database.
///
/// The session.
/// The options.
/// The cancellation token.
///
/// A Task whose result is a cursor.
///
Task> ListCollectionsAsync(IClientSessionHandle session, ListCollectionsOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Renames the collection.
///
/// The old name.
/// The new name.
/// The options.
/// The cancellation token.
void RenameCollection(string oldName, string newName, RenameCollectionOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Renames the collection.
///
/// The session.
/// The old name.
/// The new name.
/// The options.
/// The cancellation token.
void RenameCollection(IClientSessionHandle session, string oldName, string newName, RenameCollectionOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Renames the collection.
///
/// The old name.
/// The new name.
/// The options.
/// The cancellation token.
/// A task.
Task RenameCollectionAsync(string oldName, string newName, RenameCollectionOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Renames the collection.
///
/// The session.
/// The old name.
/// The new name.
/// The options.
/// The cancellation token.
///
/// A task.
///
Task RenameCollectionAsync(IClientSessionHandle session, string oldName, string newName, RenameCollectionOptions options = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Runs a command.
///
/// The result type of the command.
/// The command.
/// The read preference.
/// The cancellation token.
///
/// The result of the command.
///
TResult RunCommand(Command command, ReadPreference readPreference = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Runs a command.
///
/// The result type of the command.
/// The session.
/// The command.
/// The read preference.
/// The cancellation token.
///
/// The result of the command.
///
TResult RunCommand(IClientSessionHandle session, Command command, ReadPreference readPreference = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Runs a command.
///
/// The result type of the command.
/// The command.
/// The read preference.
/// The cancellation token.
///
/// The result of the command.
///
Task RunCommandAsync(Command command, ReadPreference readPreference = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Runs a command.
///
/// The result type of the command.
/// The session.
/// The command.
/// The read preference.
/// The cancellation token.
///
/// The result of the command.
///
Task RunCommandAsync(IClientSessionHandle session, Command command, ReadPreference readPreference = null, CancellationToken cancellationToken = default(CancellationToken));
///
/// Watches changes on all collections in a database.
///
/// 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 all collections in a database.
///
/// 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 all collections in a database.
///
/// 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 all collections in a database.
///
/// 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 IMongoDatabase instance with a different read concern setting.
///
/// The read concern.
/// A new IMongoDatabase instance with a different read concern setting.
IMongoDatabase WithReadConcern(ReadConcern readConcern);
///
/// Returns a new IMongoDatabase instance with a different read preference setting.
///
/// The read preference.
/// A new IMongoDatabase instance with a different read preference setting.
IMongoDatabase WithReadPreference(ReadPreference readPreference);
///
/// Returns a new IMongoDatabase instance with a different write concern setting.
///
/// The write concern.
/// A new IMongoDatabase instance with a different write concern setting.
IMongoDatabase WithWriteConcern(WriteConcern writeConcern);
}
}