DataRepository<T extends Entity<EntityKey>> class

Abstract class representing a generic data repository with methods for CRUD operations.

This abstract class defines the structure of a generic data repository. It is not intended to be used directly. Instead, use its implementations:

Example:

final DataRepository userRepository = RemoteDataRepository();
final DataRepository<Post> postRepository = LocalDataRepository<Post>();
Implementers

Constructors

DataRepository.local({String? id, bool backupMode = true, bool lazyMode = true, bool restoreMode = true, bool singletonMode = false, required LocalDataSource<T> source, RemoteDataSource<T>? backup, FutureConnectivityCallback? connectivity})
Constructor for creating a RemoteDataRepository implement.
const
DataRepository.remote({String? id, bool backupMode = true, bool lazyMode = true, bool restoreMode = true, bool singletonMode = true, required RemoteDataSource<T> source, LocalDataSource<T>? backup, FutureConnectivityCallback? connectivity})
Constructor for creating a RemoteDataRepository implement.
const

Properties

backupMode bool
final
hashCode int
The hash code for this object.
no setterinherited
id String?
final
isConnected Future<bool>
Getter for checking if the device is connected to the internet.
no setter
isDisconnected Future<bool>
Getter for checking if the device is disconnected from the internet.
no setter
isLocalDB bool
no setter
lazyMode bool
final
optional DataSource<T>?
An optional local data source used as a backup or cache when in cache mode.
final
primary DataSource<T>
The primary remote data source responsible for fetching data.
final
restoreMode bool
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
singletonMode bool
final

Methods

checkById(String id, {DataFieldParams? params, bool merge = true, bool? createRefs, bool? countable, bool resolveRefs = false, Ignore? ignore, bool? lazyMode, bool? backupMode}) Future<Response<T>>
Method to check data by ID with optional data source builder.
clear({DataFieldParams? params, bool? resolveRefs, Ignore? ignore, bool deleteRefs = false, bool counter = false, bool? lazyMode, bool? backupMode}) Future<Response<T>>
Method to clear data with optional data source builder.
count({DataFieldParams? params, bool? backupMode}) Future<Response<int>>
Method to count data with optional data source builder.
create(T data, {DataFieldParams? params, bool merge = true, bool createRefs = false, bool? lazyMode, bool? backupMode}) Future<Response<T>>
Method to create data with optional data source builder.
createById(String id, Map<String, dynamic> data, {DataFieldParams? params, bool merge = true, bool createRefs = false, bool? lazyMode, bool? backupMode}) Future<Response<T>>
Method to create data with optional data source builder.
createByWriters(Iterable<DataWriter> writers, {DataFieldParams? params, bool merge = true, bool createRefs = false, bool? lazyMode, bool? backupMode}) Future<Response<T>>
Method to create multiple data entries with optional data source builder.
creates(Iterable<T> data, {DataFieldParams? params, bool merge = true, bool createRefs = false, bool? lazyMode, bool? backupMode}) Future<Response<T>>
Method to create multiple data entries with optional data source builder.
deleteById(String id, {DataFieldParams? params, bool? resolveRefs, Ignore? ignore, bool counter = false, bool deleteRefs = false, bool? lazyMode, bool? backupMode}) Future<Response<T>>
Method to delete data by ID with optional data source builder.
deleteByIds(Iterable<String> ids, {DataFieldParams? params, bool? resolveRefs, Ignore? ignore, bool counter = false, bool deleteRefs = false, bool? lazyMode, bool? backupMode}) Future<Response<T>>
Method to delete data by multiple IDs with optional data source builder.
get({DataFieldParams? params, bool? countable, bool onlyUpdates = false, bool resolveRefs = false, bool resolveDocChangesRefs = false, Ignore? ignore, bool? createRefs, bool merge = true, bool? lazyMode, bool? backupMode, bool? singletonMode}) Future<Response<T>>
Method to get data with optional data source builder.
getById(String id, {DataFieldParams? params, bool? countable, bool resolveRefs = false, Ignore? ignore, bool? createRefs, bool merge = true, bool? lazyMode, bool? singletonMode, bool? backupMode}) Future<Response<T>>
Method to get data by ID with optional data source builder.
getByIds(Iterable<String> ids, {DataFieldParams? params, bool? countable, bool resolveRefs = false, bool resolveDocChangesRefs = false, Ignore? ignore, bool? createRefs, bool merge = true, bool? lazyMode, bool? backupMode, bool? singletonMode}) Future<Response<T>>
Method to get data by multiple IDs with optional data source builder.
getByQuery({DataFieldParams? params, Iterable<DataQuery> queries = const [], Iterable<DataSelection> selections = const [], Iterable<DataSorting> sorts = const [], DataFetchOptions options = const DataFetchOptions(), bool? countable, bool onlyUpdates = false, bool resolveRefs = false, bool resolveDocChangesRefs = false, Ignore? ignore, bool? createRefs, bool merge = true, bool? lazyMode, bool? backupMode, bool? singletonMode}) Future<Response<T>>
Method to get data by query with optional data source builder.
isBackupMode([bool? backupMode]) bool
isLazyMode([bool? lazyMode]) bool
isSingletonMode([bool? singletonMode]) bool
listen({DataFieldParams? params, bool? countable, bool onlyUpdates = false, bool resolveRefs = false, bool resolveDocChangesRefs = false, Ignore? ignore}) Stream<Response<T>>
Stream method to listen for data changes with optional data source builder.
listenById(String id, {DataFieldParams? params, bool? countable, bool resolveRefs = false, Ignore? ignore}) Stream<Response<T>>
Stream method to listen for data changes by ID with optional data source builder.
listenByIds(Iterable<String> ids, {DataFieldParams? params, bool? countable, bool resolveRefs = false, bool resolveDocChangesRefs = false, Ignore? ignore}) Stream<Response<T>>
Stream method to listen for data changes by multiple IDs with optional data source builder.
listenByQuery({DataFieldParams? params, Iterable<DataQuery> queries = const [], Iterable<DataSelection> selections = const [], Iterable<DataSorting> sorts = const [], DataFetchOptions options = const DataFetchOptions(), bool? countable, bool onlyUpdates = false, bool resolveRefs = false, bool resolveDocChangesRefs = false, Ignore? ignore}) Stream<Response<T>>
Stream method to listen for data changes by query with optional data source builder.
listenCount({DataFieldParams? params, Duration? interval}) Stream<Response<int>>
Method to listenCount data with optional data source builder.
modifier(Response<T> value, DataModifiers modifier) Future<Response<T>>
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
restore({DataFieldParams? params, bool onlyUpdates = false, bool? countable, bool? resolveRefs, bool resolveDocChangesRefs = false, Ignore? ignore, bool createRefs = false, bool merge = true, bool? lazyMode}) Future<void>
Method to push offline data as online data and pull online data as offline data
Method to check data by query with optional data source builder.
toString() String
A string representation of this object.
inherited
updateById(String id, Map<String, dynamic> data, {DataFieldParams? params, bool? resolveRefs, Ignore? ignore, bool updateRefs = false, bool? lazyMode, bool? backupMode}) Future<Response<T>>
Method to update data by ID with optional data source builder.
updateByIds(Iterable<DataWriter> updates, {DataFieldParams? params, bool? resolveRefs, Ignore? ignore, bool updateRefs = false, bool? lazyMode, bool? backupMode}) Future<Response<T>>
Method to update data by multiple IDs with optional data source builder.
write(List<DataBatchWriter> writers) Future<Response<void>>

Operators

operator ==(Object other) bool
The equality operator.
inherited