using BukiVedi.Shared.Entities;
using MongoDB.Driver;

namespace BukiVedi.Shared
{
    public interface IRepository<T>
         where T : IEntity
    {
        internal IMongoCollection<T> Collection { get; }

        Task<IEnumerable<TOutput>> Aggregate<TOutput>(PipelineDefinition<T, TOutput> pipeline);
        Task<T> GetById(string id);
        Task<T[]> GetAll();
        Task<T[]> Get(FilterDefinition<T> predicate);
        Task<T> GetLast(FilterDefinition<T> predicate, string sortField);
        Task<long> Count(FilterDefinition<T> predicate);
        Task<bool> Exists(FilterDefinition<T> filter);
        Task<bool> ExistById(string id);



        Task<T> Write(T obj);
        Task<IEnumerable<T>> Write(IEnumerable<T> batch);
        Task<T> WriteOrGetExists(T record, FilterDefinition<T> filter);
        Task<T> ModifyOne(FilterDefinition<T> filter, UpdateDefinition<T> update);
        Task<UpdateResult> Modify(FilterDefinition<T> filter, UpdateDefinition<T> update);
        Task<T> ReWrite(T record);
        Task<bool> TryRemove(T obj);
        Task<bool> TryRemove(FilterDefinition<T> filter);
        Task<bool> TryRemoveById(string id);
        internal Task Drop();
    }
}
