aboutsummaryrefslogtreecommitdiff
path: root/VNLib.Plugins.Extensions.Data/Abstractions/IPaginatedDataStore.cs
blob: 44c11f82fa660fe89d35633e0e37f31adbed00a1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
using System.Collections.Generic;
using System.Threading.Tasks;

namespace VNLib.Plugins.Extensions.Data.Abstractions
{
    /// <summary>
    /// Defines a Data-Store that can retirieve and manipulate paginated 
    /// data
    /// </summary>
    /// <typeparam name="T">The data-model type</typeparam>
    public interface IPaginatedDataStore<T>
    {
        /// <summary>
        /// Gets a collection of records using a pagination style query, and adds the records to the collecion
        /// </summary>
        /// <param name="collection">The collection to add records to</param>
        /// <param name="page">Pagination page to get records from</param>
        /// <param name="limit">The maximum number of items to retrieve from the store</param>
        /// <returns>A task that resolves the number of items added to the collection</returns>
        Task<int> GetPageAsync(ICollection<T> collection, int page, int limit);
        /// <summary>
        /// Gets a collection of records using a pagination style query with constraint arguments, and adds the records to the collecion
        /// </summary>
        /// <param name="collection">The collection to add records to</param>
        /// <param name="page">Pagination page to get records from</param>
        /// <param name="limit">The maximum number of items to retrieve from the store</param>
        /// <param name="constraints">A params array of strings to constrain the result set from the db</param>
        /// <returns>A task that resolves the number of items added to the collection</returns>
        Task<int> GetPageAsync(ICollection<T> collection, int page, int limit, params string[] constraints);
    }
    
}