diff options
author | vnugent <public@vaughnnugent.com> | 2023-08-28 21:51:11 -0400 |
---|---|---|
committer | vnugent <public@vaughnnugent.com> | 2023-08-28 21:51:11 -0400 |
commit | c68c7762ce9023af8b65ce58adee167fc9788ee1 (patch) | |
tree | 7fd1e335200e6872d3811b7a18ce81fd4d93d8f1 /lib/VNLib.Plugins.Extensions.Data/src/Abstractions/IDataStore.cs | |
parent | 9af5ea65f177bc3fa6e96ecc732251adf5482bfa (diff) |
big data updates, secret file support,
Diffstat (limited to 'lib/VNLib.Plugins.Extensions.Data/src/Abstractions/IDataStore.cs')
-rw-r--r-- | lib/VNLib.Plugins.Extensions.Data/src/Abstractions/IDataStore.cs | 107 |
1 files changed, 15 insertions, 92 deletions
diff --git a/lib/VNLib.Plugins.Extensions.Data/src/Abstractions/IDataStore.cs b/lib/VNLib.Plugins.Extensions.Data/src/Abstractions/IDataStore.cs index 1c8174c..bdd1b6c 100644 --- a/lib/VNLib.Plugins.Extensions.Data/src/Abstractions/IDataStore.cs +++ b/lib/VNLib.Plugins.Extensions.Data/src/Abstractions/IDataStore.cs @@ -22,14 +22,6 @@ * along with this program. If not, see https://www.gnu.org/licenses/. */ -using System; -using System.Threading; -using System.Threading.Tasks; -using System.Collections.Generic; - -using VNLib.Utils; - - namespace VNLib.Plugins.Extensions.Data.Abstractions { /// <summary> @@ -37,99 +29,30 @@ namespace VNLib.Plugins.Extensions.Data.Abstractions /// operations that retrieve or manipulate records of data /// </summary> /// <typeparam name="T">The data-model type</typeparam> - public interface IDataStore<T> + public interface IDataStore<T> where T: class, IDbModel { /// <summary> - /// Gets the total number of records in the current store - /// </summary> - /// <param name="cancellation">A cancellation token to cancel the operation</param> - /// <returns>A task that resolves the number of records in the store</returns> - Task<long> GetCountAsync(CancellationToken cancellation = default); - /// <summary> - /// Gets the number of records that belong to the specified constraint - /// </summary> - /// <param name="specifier">A specifier to constrain the reults</param> - /// <param name="cancellation">A cancellation token to cancel the operation</param> - /// <returns>The number of records that belong to the specifier</returns> - Task<long> GetCountAsync(string specifier, CancellationToken cancellation = default); - /// <summary> - /// Gets a record from its key + /// Gets a unique ID for a new record being added to the store /// </summary> - /// <param name="key">The key identifying the unique record</param> - /// <param name="cancellation">A cancellation token to cancel the operation</param> - /// <returns>A promise that resolves the record identified by the specified key</returns> - Task<T?> GetSingleAsync(string key, CancellationToken cancellation = default); + string GetNewRecordId(); + /// <summary> - /// Gets a record from its key + /// Gets a new <see cref="TransactionalDbContext"/> ready for use /// </summary> - /// <param name="specifiers">A variable length specifier arguemnt array for retreiving a single application</param> /// <returns></returns> - Task<T?> GetSingleAsync(params string[] specifiers); - /// <summary> - /// Gets a record from the store with a partial model, intended to complete the model - /// </summary> - /// <param name="record">The partial model used to query the store</param> - /// <param name="cancellation">A cancellation token to cancel the operation</param> - /// <returns>A task the resolves the completed data-model</returns> - Task<T?> GetSingleAsync(T record, CancellationToken cancellation = default); - /// <summary> - /// Fills a collection with enires retireved from the store using the specifer - /// </summary> - /// <param name="collection">The collection to add entires to</param> - /// <param name="specifier">A specifier argument to constrain results</param> - /// <param name="limit">The maximum number of elements to retrieve</param> - /// <param name="cancellation">A cancellation token to cancel the operation</param> - /// <returns>A Task the resolves to the number of items added to the collection</returns> - Task<ERRNO> GetCollectionAsync(ICollection<T> collection, string specifier, int limit, CancellationToken cancellation = default); - /// <summary> - /// Fills a collection with enires retireved from the store using a variable length specifier - /// parameter - /// </summary> - /// <param name="collection">The collection to add entires to</param> - /// <param name="limit">The maximum number of elements to retrieve</param> - /// <param name="args"></param> - /// <returns>A Task the resolves to the number of items added to the collection</returns> - Task<ERRNO> GetCollectionAsync(ICollection<T> collection, int limit, params string[] args); - /// <summary> - /// Updates an entry in the store with the specified record - /// </summary> - /// <param name="record">The record to update</param> - /// <param name="cancellation">A cancellation token to cancel the operation</param> - /// <returns>A task the resolves an error code (should evaluate to false on failure, and true on success)</returns> - Task<ERRNO> UpdateAsync(T record, CancellationToken cancellation = default); - /// <summary> - /// Creates a new entry in the store representing the specified record - /// </summary> - /// <param name="record">The record to add to the store</param> - /// <param name="cancellation">A cancellation token to cancel the operation</param> - /// <returns>A task the resolves an error code (should evaluate to false on failure, and true on success)</returns> - Task<ERRNO> CreateAsync(T record, CancellationToken cancellation = default); - /// <summary> - /// Deletes one or more entrires from the store matching the specified record - /// </summary> - /// <param name="record">The record to remove from the store</param> - /// <param name="cancellation">A cancellation token to cancel the operation</param> - /// <returns>A task the resolves the number of records removed(should evaluate to false on failure, and deleted count on success)</returns> - Task<ERRNO> DeleteAsync(T record, CancellationToken cancellation = default); - /// <summary> - /// Deletes one or more entires from the store matching the specified unique key - /// </summary> - /// <param name="key">The unique key that identifies the record</param> - /// <param name="cancellation">A cancellation token to cancel the operation</param> - /// <returns>A task the resolves the number of records removed(should evaluate to false on failure, and deleted count on success)</returns> - Task<ERRNO> DeleteAsync(string key, CancellationToken cancellation = default); + IDbContextHandle GetNewContext(); + /// <summary> - /// Deletes one or more entires from the store matching the supplied specifiers + /// Represents a table of ef queryies that can be used to execute operations against a a database /// </summary> - /// <param name="specifiers">A variable length array of specifiers used to delete one or more entires</param> - /// <returns>A task the resolves the number of records removed(should evaluate to false on failure, and deleted count on success)</returns> - Task<ERRNO> DeleteAsync(params string[] specifiers); + IDbQueryLookup<T> QueryTable { get; } + /// <summary> - /// Updates an entry in the store if it exists, or creates a new entry if one does not already exist + /// Updates the current record (if found) to the new record before + /// storing the updates. /// </summary> - /// <param name="record">The record to add to the store</param> - /// <param name="cancellation">A cancellation token to cancel the operation</param> - /// <returns>A task the resolves the result of the operation</returns> - Task<ERRNO> AddOrUpdateAsync(T record, CancellationToken cancellation = default); + /// <param name="newRecord">The new record to capture data from</param> + /// <param name="existing">The current record to be updated</param> + void OnRecordUpdate(T newRecord, T existing); } } |