using System;
using System.Linq.Expressions;
using System.Threading;
using System.Threading.Tasks;
using MongoDB.Driver;
using MongoDbGenericRepository.DataAccess.Base;
using MongoDbGenericRepository.Models;
namespace MongoDbGenericRepository.DataAccess.Update
{
///
/// A interface for updating documents in MongoDb.
///
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.
/// An optional cancellation token.
Task UpdateOneAsync(TDocument modifiedDocument, CancellationToken cancellationToken = default)
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.
/// An optional cancellation token.
Task UpdateOneAsync(TDocument documentToModify, UpdateDefinition update, CancellationToken cancellationToken = default)
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.
/// An optional cancellation token.
Task UpdateOneAsync(TDocument documentToModify, Expression> field, TField value, CancellationToken cancellationToken = default)
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.
/// An optional cancellation token.
Task UpdateOneAsync(FilterDefinition filter, Expression> field, TField value, string partitionKey = null, CancellationToken cancellationToken = default)
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.
/// An optional cancellation token.
Task UpdateOneAsync(Expression> filter, Expression> field, TField value, string partitionKey = null, CancellationToken cancellationToken = default)
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)
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)
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)
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)
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)
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.
/// The optional cancellation token.
bool UpdateOne(TDocument modifiedDocument, CancellationToken cancellationToken = default)
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.
/// The optional cancellation token.
bool UpdateOne(TDocument documentToModify, UpdateDefinition update, CancellationToken cancellationToken = default)
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.
/// The optional cancellation token.
bool UpdateOne(TDocument documentToModify, Expression> field, TField value, CancellationToken cancellationToken = default)
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.
/// The optional cancellation token.
bool UpdateOne(FilterDefinition filter, Expression> field, TField value, string partitionKey = null, CancellationToken cancellationToken = default)
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.
/// The optional cancellation token.
bool UpdateOne(Expression> filter, Expression> field, TField value, string partitionKey = null, CancellationToken cancellationToken = default)
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)
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)
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)
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)
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)
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.
/// The optional cancellation token.
Task UpdateManyAsync(Expression> filter, Expression> field, TField value, string partitionKey = null, CancellationToken cancellationToken = default)
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.
/// The optional cancellation token.
Task UpdateManyAsync(FilterDefinition filter, Expression> field, TField value, string partitionKey = null, CancellationToken cancellationToken = default)
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 update definition
/// The value of the partition key.
/// The optional cancellation token.
Task UpdateManyAsync(Expression> filter, UpdateDefinition update, string partitionKey = null, CancellationToken cancellationToken = default)
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 update definition.
/// The value of the partition key.
/// The optional cancellation token.
Task UpdateManyAsync(FilterDefinition filter, UpdateDefinition updateDefinition, string partitionKey = null, CancellationToken cancellationToken = default)
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.
/// The optional cancellation token.
long UpdateMany(Expression> filter, Expression> field, TField value, string partitionKey = null, CancellationToken cancellationToken = default)
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.
/// The optional cancellation token.
long UpdateMany(FilterDefinition filter, Expression> field, TField value, string partitionKey = null, CancellationToken cancellationToken = default)
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 update definition.
/// The value of the partition key.
/// The optional cancellation token.
long UpdateMany(FilterDefinition filter, UpdateDefinition updateDefinition, string partitionKey = null, CancellationToken cancellationToken = default)
where TDocument : IDocument
where TKey : IEquatable;
}
}