using System; using System.Linq.Expressions; using System.Threading; using System.Threading.Tasks; using MongoDB.Driver; using MongoDB.Driver.Linq; using MongoDbGenericRepository.DataAccess.Base; using MongoDbGenericRepository.Models; namespace MongoDbGenericRepository.DataAccess.Update { public interface IMongoDbUpdater : IDataAccessBase { /// /// Asynchronously Updates a document. /// /// The type representing a Document. /// The type of the primary key for a Document. /// The document with the modifications you want to persist. Task UpdateOneAsync(TDocument modifiedDocument) where TDocument : IDocument where TKey : IEquatable; /// /// Takes a document you want to modify and applies the update you have defined in MongoDb. /// /// The type representing a Document. /// The type of the primary key for a Document. /// The document you want to modify. /// The update definition for the document. Task UpdateOneAsync(TDocument documentToModify, UpdateDefinition update) where TDocument : IDocument where TKey : IEquatable; /// /// Updates the property field with the given value update a property field in entities. /// /// The type representing a Document. /// The type of the primary key for a Document. /// The type of the field. /// The document you want to modify. /// The field selector. /// The new value of the property field. Task UpdateOneAsync(TDocument documentToModify, Expression> field, TField value) where TDocument : IDocument where TKey : IEquatable; /// /// Updates the property field with the given value update a property field in entities. /// /// The type representing a Document. /// The type of the primary key for a Document. /// The type of the field. /// The document filter. /// The field selector. /// The new value of the property field. /// The value of the partition key. Task UpdateOneAsync(FilterDefinition filter, Expression> field, TField value, string partitionKey = null) where TDocument : IDocument where TKey : IEquatable; /// /// For the entity selected by the filter, updates the property field with the given value. /// /// The type representing a Document. /// The type of the primary key for a Document. /// The type of the field. /// The document filter. /// The field selector. /// The new value of the property field. /// The partition key for the document. Task UpdateOneAsync(Expression> filter, Expression> field, TField value, string partitionKey = null) where TDocument : IDocument where TKey : IEquatable; /// /// Updates a document. /// /// The type representing a Document. /// The type of the primary key for a Document. /// The client session. /// The document with the modifications you want to persist. /// The optional cancellation token. /// Task UpdateOneAsync(IClientSessionHandle session, TDocument modifiedDocument, CancellationToken cancellationToken = default(CancellationToken)) where TDocument : IDocument where TKey : IEquatable; /// /// Updates a document. /// /// The type representing a Document. /// The type of the primary key for a Document. /// The client session. /// The document to modify. /// The update definition. /// The optional cancellation token. /// Task UpdateOneAsync(IClientSessionHandle session, TDocument documentToModify, UpdateDefinition update, CancellationToken cancellationToken = default(CancellationToken)) where TDocument : IDocument where TKey : IEquatable; /// /// Updates a document. /// /// The type representing a Document. /// The type of the primary key for a Document. /// The type of the field to update. /// The client session. /// The document to modify. /// The field to update. /// The value of the field. /// The optional cancellation token. /// Task UpdateOneAsync(IClientSessionHandle session, TDocument documentToModify, Expression> field, TField value, CancellationToken cancellationToken = default(CancellationToken)) where TDocument : IDocument where TKey : IEquatable; /// /// Updates a document. /// /// The type representing a Document. /// The type of the primary key for a Document. /// The type of the field to update. /// The client session. /// The filter for the update. /// The field to update. /// The value of the field. /// The optional partition key. /// The optional cancellation token. /// Task UpdateOneAsync(IClientSessionHandle session, FilterDefinition filter, Expression> field, TField value, string partitionKey = null, CancellationToken cancellationToken = default(CancellationToken)) where TDocument : IDocument where TKey : IEquatable; /// /// Updates a document. /// /// The type representing a Document. /// The type of the primary key for a Document. /// The type of the field to update. /// The client session. /// The filter for the update. /// The field to update. /// The value of the field. /// The optional partition key. /// The optional cancellation token. /// Task UpdateOneAsync(IClientSessionHandle session, Expression> filter, Expression> field, TField value, string partitionKey = null, CancellationToken cancellationToken = default(CancellationToken)) where TDocument : IDocument where TKey : IEquatable; /// /// Updates a document. /// /// The type representing a Document. /// The type of the primary key for a Document. /// The document with the modifications you want to persist. bool UpdateOne(TDocument modifiedDocument) where TDocument : IDocument where TKey : IEquatable; /// /// Takes a document you want to modify and applies the update you have defined in MongoDb. /// /// The type representing a Document. /// The type of the primary key for a Document. /// The document you want to modify. /// The update definition for the document. bool UpdateOne(TDocument documentToModify, UpdateDefinition update) where TDocument : IDocument where TKey : IEquatable; /// /// Updates the property field with the given value update a property field in entities. /// /// The type representing a Document. /// The type of the primary key for a Document. /// The type of the field. /// The document you want to modify. /// The field selector. /// The new value of the property field. bool UpdateOne(TDocument documentToModify, Expression> field, TField value) where TDocument : IDocument where TKey : IEquatable; /// /// Updates the property field with the given value. /// /// The type representing a Document. /// The type of the primary key for a Document. /// The type of the field. /// The document filter. /// The field selector. /// The new value of the property field. /// The value of the partition key. bool UpdateOne(FilterDefinition filter, Expression> field, TField value, string partitionKey = null) where TDocument : IDocument where TKey : IEquatable; /// /// For the entity selected by the filter, updates the property field with the given value. /// /// The type representing a Document. /// The type of the primary key for a Document. /// The type of the field. /// The document filter. /// The field selector. /// The new value of the property field. /// The partition key for the document. bool UpdateOne(Expression> filter, Expression> field, TField value, string partitionKey = null) where TDocument : IDocument where TKey : IEquatable; /// /// Updates a document. /// /// The type representing a Document. /// The type of the primary key for a Document. /// The client session. /// The document with the modifications you want to persist. /// The optional cancellation token. /// bool UpdateOne(IClientSessionHandle session, TDocument modifiedDocument, CancellationToken cancellationToken = default(CancellationToken)) where TDocument : IDocument where TKey : IEquatable; /// /// Updates a document. /// /// The type representing a Document. /// The type of the primary key for a Document. /// The client session. /// The document to modify. /// The update definition. /// The optional cancellation token. /// bool UpdateOne(IClientSessionHandle session, TDocument documentToModify, UpdateDefinition update, CancellationToken cancellationToken = default(CancellationToken)) where TDocument : IDocument where TKey : IEquatable; /// /// Updates a document. /// /// The type representing a Document. /// The type of the primary key for a Document. /// The type of the field to update. /// The client session. /// The document to modify. /// The field to update. /// The value of the field. /// The optional cancellation token. /// bool UpdateOne(IClientSessionHandle session, TDocument documentToModify, Expression> field, TField value, CancellationToken cancellationToken = default(CancellationToken)) where TDocument : IDocument where TKey : IEquatable; /// /// Updates a document. /// /// The type representing a Document. /// The type of the primary key for a Document. /// The type of the field to update. /// The client session. /// The filter for the update. /// The field to update. /// The value of the field. /// The optional partition key. /// The optional cancellation token. /// bool UpdateOne(IClientSessionHandle session, FilterDefinition filter, Expression> field, TField value, string partitionKey = null, CancellationToken cancellationToken = default(CancellationToken)) where TDocument : IDocument where TKey : IEquatable; /// /// Updates a document. /// /// The type representing a Document. /// The type of the primary key for a Document. /// The type of the field to update. /// The client session. /// The filter for the update. /// The field to update. /// The value of the field. /// The optional partition key. /// The optional cancellation token. /// bool UpdateOne(IClientSessionHandle session, Expression> filter, Expression> field, TField value, string partitionKey = null, CancellationToken cancellationToken = default(CancellationToken)) where TDocument : IDocument where TKey : IEquatable; /// /// For the entities selected by the filter, updates the property field with the given value. /// /// The type representing a Document. /// The type of the primary key for a Document. /// The type of the field. /// The document filter. /// The field selector. /// The new value of the property field. /// The partition key for the document. Task UpdateManyAsync(Expression> filter, Expression> field, TField value, string partitionKey = null) where TDocument : IDocument where TKey : IEquatable; /// /// For the entities selected by the filter, updates the property field with the given value. /// /// The type representing a Document. /// The type of the primary key for a Document. /// The type of the field. /// The document filter. /// The field selector. /// The new value of the property field. /// The value of the partition key. Task UpdateManyAsync(FilterDefinition filter, Expression> field, TField value, string partitionKey = null) where TDocument : IDocument where TKey : IEquatable; /// /// For the entities selected by the filter, apply the update definition. /// /// The type representing a Document. /// The type of the primary key for a Document. /// The document filter. /// The field selector. /// The new value of the property field. /// The value of the partition key. Task UpdateManyAsync(Expression> filter, UpdateDefinition update, string partitionKey = null) where TDocument : IDocument where TKey : IEquatable; /// /// For the entities selected by the filter, apply the update definition. /// /// The type representing a Document. /// The type of the primary key for a Document. /// The type of the field. /// The document filter. /// The update definition. /// The value of the partition key. Task UpdateManyAsync(FilterDefinition filter, UpdateDefinition updateDefinition, string partitionKey = null) where TDocument : IDocument where TKey : IEquatable; /// /// For the entities selected by the filter, updates the property field with the given value. /// /// The type representing a Document. /// The type of the primary key for a Document. /// The type of the field. /// The document filter. /// The field selector. /// The new value of the property field. /// The partition key for the document. long UpdateMany(Expression> filter, Expression> field, TField value, string partitionKey = null) where TDocument : IDocument where TKey : IEquatable; /// /// For the entities selected by the filter, updates the property field with the given value. /// /// The type representing a Document. /// The type of the primary key for a Document. /// The type of the field. /// The document filter. /// The field selector. /// The new value of the property field. /// The value of the partition key. long UpdateMany(FilterDefinition filter, Expression> field, TField value, string partitionKey = null) where TDocument : IDocument where TKey : IEquatable; /// /// For the entities selected by the filter, apply the update definition. /// /// The type representing a Document. /// The type of the primary key for a Document. /// The type of the field. /// The document filter. /// The update definition. /// The value of the partition key. long UpdateMany(FilterDefinition filter, UpdateDefinition UpdateDefinition, string partitionKey = null) where TDocument : IDocument where TKey : IEquatable; /// /// Gets a IMongoQueryable for a potentially partitioned document type and a filter. /// /// The document type. /// The type of the primary key. /// The filter definition. /// The collection partition key. /// IMongoQueryable GetQuery(Expression> filter, string partitionKey = null) where TDocument : IDocument where TKey : IEquatable; /// /// Gets a collections for a potentially partitioned document type. /// /// The document type. /// The type of the primary key. /// The document. /// IMongoCollection HandlePartitioned(TDocument document) where TDocument : IDocument where TKey : IEquatable; /// /// Gets a collections for a potentially partitioned document type. /// /// The document type. /// The type of the primary key. /// The collection partition key. /// IMongoCollection HandlePartitioned(string partitionKey) where TDocument : IDocument where TKey : IEquatable; /// /// Gets a collections for the type TDocument with a partition key. /// /// The document type. /// The type of the primary key. /// The collection partition key. /// IMongoCollection GetCollection(string partitionKey = null) where TDocument : IDocument where TKey : IEquatable; } }