using MongoDB.Driver;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Linq.Expressions;
using MongoDbGenericRepository.Models;
namespace MongoDbGenericRepository
{
///
/// The IReadOnlyMongoRepository exposes the readonly functionality of the BaseMongoRepository.
///
public interface IReadOnlyMongoRepository
{
///
/// The connection string.
///
string ConnectionString { get; set; }
///
/// The database name.
///
string DatabaseName { get; set; }
#region Read
///
/// Asynchronously returns one document given its id.
///
/// The type representing a Document.
/// The Id of the document you want to get.
/// An optional partition key.
Task GetByIdAsync(Guid id, string partitionKey = null) where TDocument : IDocument;
///
/// Returns one document given its id.
///
/// The type representing a Document.
/// The Id of the document you want to get.
/// An optional partition key.
TDocument GetById(Guid id, string partitionKey = null) where TDocument : IDocument;
///
/// Asynchronously returns one document given an expression filter.
///
/// The type representing a Document.
/// A LINQ expression filter.
/// An optional partition key.
Task GetOneAsync(Expression> filter, string partitionKey = null) where TDocument : IDocument;
///
/// Returns one document given an expression filter.
///
/// The type representing a Document.
/// A LINQ expression filter.
/// An optional partition key.
TDocument GetOne(Expression> filter, string partitionKey = null) where TDocument : IDocument;
///
/// Returns a collection cursor.
///
/// The type representing a Document.
/// A LINQ expression filter.
/// An optional partition key.
IFindFluent GetCursor(Expression> filter, string partitionKey = null) where TDocument : IDocument;
///
/// Asynchronously returns true if any of the document of the collection matches the filter condition.
///
/// The type representing a Document.
/// A LINQ expression filter.
/// An optional partition key.
Task AnyAsync(Expression> filter, string partitionKey = null) where TDocument : IDocument;
///
/// Returns true if any of the document of the collection matches the filter condition.
///
/// The type representing a Document.
/// A LINQ expression filter.
/// An optional partition key.
bool Any(Expression> filter, string partitionKey = null) where TDocument : IDocument;
///
/// Asynchronously returns a list of the documents matching the filter condition.
///
/// The type representing a Document.
/// A LINQ expression filter.
/// An optional partition key.
Task> GetAllAsync(Expression> filter, string partitionKey = null) where TDocument : IDocument;
///
/// Returns a list of the documents matching the filter condition.
///
/// The type representing a Document.
/// A LINQ expression filter.
/// An optional partition key.
List GetAll(Expression> filter, string partitionKey = null) where TDocument : IDocument;
///
/// Asynchronously counts how many documents match the filter condition.
///
/// The type representing a Document.
/// A LINQ expression filter.
/// An optional partition key.
Task CountAsync(Expression> filter, string partitionKey = null) where TDocument : IDocument;
///
/// Counts how many documents match the filter condition.
///
/// The type representing a Document.
/// A LINQ expression filter.
/// An optional partition key.
long Count(Expression> filter, string partitionKey = null) where TDocument : IDocument;
#endregion
#region Read TKey
///
/// Asynchronously returns one document given its id.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// The Id of the document you want to get.
/// An optional partition key.
Task GetByIdAsync(TKey id, string partitionKey = null)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Returns one document given its id.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// The Id of the document you want to get.
/// An optional partition key.
TDocument GetById(TKey id, string partitionKey = null)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Asynchronously returns one document given an expression filter.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// A LINQ expression filter.
/// An optional partition key.
Task GetOneAsync(Expression> filter, string partitionKey = null)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Returns one document given an expression filter.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// A LINQ expression filter.
/// An optional partition key.
TDocument GetOne(Expression> filter, string partitionKey = null)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Returns a collection cursor.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// A LINQ expression filter.
/// An optional partition key.
IFindFluent GetCursor(Expression> filter, string partitionKey = null)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Returns true if any of the document of the collection matches the filter condition.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// A LINQ expression filter.
/// An optional partition key.
Task AnyAsync(Expression> filter, string partitionKey = null)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Returns true if any of the document of the collection matches the filter condition.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// A LINQ expression filter.
/// An optional partition key.
bool Any(Expression> filter, string partitionKey = null)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Asynchronously returns a list of the documents matching the filter condition.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// A LINQ expression filter.
/// An optional partition key.
Task> GetAllAsync(Expression> filter, string partitionKey = null)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Returns a list of the documents matching the filter condition.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// A LINQ expression filter.
/// An optional partition key.
List GetAll(Expression> filter, string partitionKey = null)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Asynchronously counts how many documents match the filter condition.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// A LINQ expression filter.
/// An optional partitionKey
Task CountAsync(Expression> filter, string partitionKey = null)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Counts how many documents match the filter condition.
///
/// The type representing a Document.
/// The type of the primary key for a Document.
/// A LINQ expression filter.
/// An optional partitionKey
long Count(Expression> filter, string partitionKey = null)
where TDocument : IDocument
where TKey : IEquatable;
#endregion
#region Min / Max
///
/// Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter.
///
/// The document type.
/// A LINQ expression filter.
/// A property selector to order by descending.
/// An optional partitionKey.
Task GetByMaxAsync(Expression> filter, Expression> orderByDescending, string partitionKey = null)
where TDocument : IDocument;
///
/// Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter.
///
/// The document type.
/// A LINQ expression filter.
/// A property selector to order by descending.
/// An optional partitionKey.
///
TDocument GetByMax(Expression> filter, Expression> orderByDescending, string partitionKey = null)
where TDocument : IDocument;
///
/// Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter.
///
/// The document type.
/// A LINQ expression filter.
/// A property selector to order by ascending.
/// An optional partitionKey.
Task GetByMinAsync(Expression> filter, Expression> orderByAscending, string partitionKey = null)
where TDocument : IDocument;
///
/// Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter.
///
/// The document type.
/// A LINQ expression filter.
/// A property selector to order by ascending.
/// An optional partitionKey.
TDocument GetByMin(Expression> filter, Expression> orderByAscending, string partitionKey = null)
where TDocument : IDocument;
///
/// Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter.
///
/// The document type.
/// The type of the primary key.
/// A LINQ expression filter.
/// A property selector to order by descending.
/// An optional partitionKey.
Task GetByMaxAsync(Expression> filter, Expression> orderByDescending, string partitionKey = null)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Gets the document with the maximum value of a specified property in a MongoDB collections that is satisfying the filter.
///
/// The document type.
/// The type of the primary key.
/// A LINQ expression filter.
/// A property selector to order by descending.
/// An optional partitionKey.
TDocument GetByMax(Expression> filter, Expression> orderByDescending, string partitionKey = null)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Gets the document with the minimum value of a specified property in a MongoDB collections that is satisfying the filter.
///
/// The document type.
/// The type of the primary key.
/// A LINQ expression filter.
/// A property selector to order by ascending.
/// An optional partitionKey.
Task GetByMinAsync(Expression> filter, Expression> orderByAscending, string partitionKey = null)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Gets the document with the minimum value of a specified property in a MongoDB collections that is satisfying the filter.
///
/// The document type.
/// The type of the primary key.
/// A LINQ expression filter.
/// A property selector to order by ascending.
/// An optional partitionKey.
TDocument GetByMin(Expression> filter, Expression> orderByAscending, string partitionKey = null)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Gets the maximum value of a property in a mongodb collections that is satisfying the filter.
///
/// The document type.
/// The type of the value used to order the query.
/// A LINQ expression filter.
/// A property selector to order by ascending.
/// An optional partitionKey.
Task GetMaxValueAsync(Expression> filter, Expression> maxValueSelector, string partitionKey = null)
where TDocument : IDocument;
///
/// Gets the maximum value of a property in a mongodb collections that is satisfying the filter.
///
/// The document type.
/// The type of the primary key.
/// A LINQ expression filter.
/// A property selector to order by ascending.
/// An optional partitionKey.
Task GetMaxValueAsync(Expression> filter, Expression> maxValueSelector, string partitionKey = null)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Gets the maximum value of a property in a mongodb collections that is satisfying the filter.
///
/// The document type.
/// The type of the value used to order the query.
/// A LINQ expression filter.
/// A property selector to order by ascending.
/// An optional partitionKey.
TValue GetMaxValue(Expression> filter, Expression> maxValueSelector, string partitionKey = null)
where TDocument : IDocument;
///
/// Gets the maximum value of a property in a mongodb collections that is satisfying the filter.
///
/// The document type.
/// The type of the primary key.
/// A LINQ expression filter.
/// A property selector to order by ascending.
/// An optional partitionKey.
TValue GetMaxValue(Expression> filter, Expression> orderByDescending, string partitionKey = null)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Gets the minimum value of a property in a mongodb collections that is satisfying the filter.
///
/// The document type.
/// The type of the value used to order the query.
/// A LINQ expression filter.
/// A property selector to order by ascending.
/// An optional partition key.
Task GetMinValueAsync(Expression> filter, Expression> minValueSelector, string partitionKey = null)
where TDocument : IDocument;
///
/// Gets the minimum value of a property in a mongodb collections that is satisfying the filter.
///
/// The document type.
/// The type of the primary key.
/// The type of the value used to order the query.
/// A LINQ expression filter.
/// A property selector to order by ascending.
/// An optional partition key.
Task GetMinValueAsync(Expression> filter, Expression> minValueSelector, string partitionKey = null)
where TDocument : IDocument
where TKey : IEquatable;
///
/// Gets the minimum value of a property in a mongodb collections that is satisfying the filter.
///
/// The document type.
/// The type of the value used to order the query.
/// A LINQ expression filter.
/// A property selector to order by ascending.
/// An optional partition key.
TValue GetMinValue(Expression> filter, Expression> minValueSelector, string partitionKey = null)
where TDocument : IDocument;
///
/// Gets the minimum value of a property in a mongodb collections that is satisfying the filter.
///
/// The document type.
/// The type of the primary key.
/// The type of the value used to order the query.
/// A LINQ expression filter.
/// A property selector to order by ascending.
/// An optional partition key.
TValue GetMinValue(Expression> filter, Expression> minValueSelector, string partitionKey = null)
where TDocument : IDocument
where TKey : IEquatable;
#endregion
}
}