using MongoDB.Bson;
using MongoDB.Driver;

namespace adas_core.Application.Repositories.Interfaces;

public interface IMongoRepository<T>
{
    IMongoCollection<T> Collection { get; }

    /// <summary>
    /// Gets the name of the collection.
    /// </summary>
    /// <returns>The name of the collection.</returns>
    string GetCollectionName();
    /// <summary>
    /// Asynchronously inserts a single object of type <typeparamref name="T"/>.
    /// </summary>
    /// <param name="obj">The object to insert.</param>
    /// <returns>A task that represents the asynchronous insert operation.</returns>
    Task InsertOneAsync(T obj);
    /// <summary>
    /// Asynchronously deletes the entity identified by the specified identifier and returns the deleted entity.
    /// </summary>
    /// <param name="id">The unique identifier of the entity to delete.</param>
    /// <returns>A task that represents the asynchronous operation, containing the deleted entity of type <typeparamref name="T"/>, or <c>null</c> if no matching entity was found.</returns>
    Task<T?> DeleteAsync(ObjectId id);
    /// <summary>
    /// Asynchronously updates an existing document identified by the specified identifier with the provided object data.
    /// </summary>
    /// <param name="id">The unique identifier of the document to update.</param>
    /// <param name="obj">The object containing the updated values to persist.</param>
    Task UpdateOneAsync(ObjectId id, T obj);
}