IReadModelStore<TKey> Interface¶
In the Crystal Sharp framework, IReadModelStore<TKey>
is a designated interface that enables the execution of operations on the read model store. Here, <TKey>
denotes the data type of the Id
property, which serves as the primary key within the read model store.
Following are the methods of the IReadModelStore<TKey>
interface:
Task<bool> Store<T>(T record, CancellationToken cancellationToken = default) where T : class, IReadModel<TKey> | Saves the record in the read model store. |
Task<bool> BulkStore<T>(IEnumerable<T> records, CancellationToken cancellationToken = default) where T : class, IReadModel<TKey> | Saves the records in bulk in the read model store. |
Task<bool> Update<T>(T record, CancellationToken cancellationToken = default) where T : class, IReadModel<TKey> | Updates the record in the read model store. |
Task<bool> Delete<T>(TKey id, CancellationToken cancellationToken = default) where T : class, IReadModel<TKey> | Hard delete. Deletes the record permanently from the read model store by Id. |
Task<bool> Delete<T>(Guid globalUId, CancellationToken cancellationToken = default) where T : class, IReadModel<TKey> | Hard delete. Deletes the record permanently from the read model store by GlobalUId. |
Task<bool> SoftDelete<T>(TKey id, CancellationToken cancellationToken = default) where T : class, IReadModel<TKey> | Soft deletes the record in the read model store by Id so it can be restored later if needed. |
Task<bool> SoftDelete<T>(Guid globalUId, CancellationToken cancellationToken = default) where T : class, IReadModel<TKey> | Soft deletes the record in the read model store by GlobalUId so it can be restored later if needed. |
Task<bool> BulkDelete<T>(IEnumerable<TKey> ids, CancellationToken cancellationToken = default) where T : class, IReadModel<TKey> | Hard delete. Deletes the records permanently from the read model store in bulk by the list of Id provided. |
Task<bool> BulkDelete<T>(IEnumerable<Guid> globalUIds, CancellationToken cancellationToken = default) where T : class, IReadModel<TKey> | Hard delete. Deletes the records permanently from the read model store in bulk by the list of GlobalUId provided. |
Task<bool> BulkSoftDelete<T>(IEnumerable<TKey> ids, CancellationToken cancellationToken = default) where T : class, IReadModel<TKey> | Soft deletes the record in the read model store in bulk by using the list of Id provided. Soft deleted records are recoverable and can be restored later if needed. |
Task<bool> BulkSoftDelete<T>(IEnumerable<Guid> globalUIds, CancellationToken cancellationToken = default) where T : class, IReadModel<TKey> | Soft deletes the record in the read model store in bulk by using the list of GlobalUId provided. Soft deleted records are recoverable and can be restored later if needed. |
Task<bool> Restore<T>(TKey id, CancellationToken cancellationToken = default) where T : class, IReadModel<TKey> | Restores the soft deleted record by Id. |
Task<bool> Restore<T>(Guid globalUId, CancellationToken cancellationToken = default) where T : class, IReadModel<TKey> | Restores the soft deleted record by GlobalUId. |
Task<bool> BulkRestore<T>(IEnumerable<TKey> ids, CancellationToken cancellationToken = default) where T : class, IReadModel<TKey> | Restores the soft deleted record in bulk by the list of Id provided. |
Task<bool> BulkRestore<T>(IEnumerable<Guid> globalUIds, CancellationToken cancellationToken = default) where T : class, IReadModel<TKey> | Restores the soft deleted record in bulk by the list of GlobalUId provided. |
Task<long> Count<T>(RecordMode recordMode = RecordMode.Active, CancellationToken cancellationToken = default) where T : class, IReadModel<TKey> | Returns the count of records according to the specified parameters. |
Task<long> Count<T>(Expression<Func<T, bool>> predicate, CancellationToken cancellationToken = default) where T : class, IReadModel<TKey> | Returns the count of records based on the predicate. |
Task<T> Find<T>(TKey id, CancellationToken cancellationToken = default) where T : class, IReadModel<TKey> | Finds the record by Id. |
Task<T> Find<T>(Guid globalUId, CancellationToken cancellationToken = default) where T : class, IReadModel<TKey> | Finds the record by GlobalUId. |
Task<PagedResult<T>> Get<T>(int skip = 0, int take = 10, Expression<Func<T, bool>> predicate = null, RecordMode recordMode = RecordMode.Active, string sortColumn = “”, DataSortMode sortMode = DataSortMode.None, CancellationToken cancellationToken = default) where T : class, IReadModel<TKey> | Returns the records according to the specified parameters. |
Task<PagedResult<T>> Search<T>(string term, bool useWildcard, int skip = 0, int take = 10, RecordMode recordMode = RecordMode.Active, string sortColumn = “”, DataSortMode sortMode = DataSortMode.None, CancellationToken cancellationToken = default) where T : class, IReadModel<TKey> | Retrieves the records according to the specified parameters. This method is specific to Elasticsearch. |