FirebaseStore<T> class
abstract
A store the provides access to a selected part of a firebase database.
This class is the core element of the library. It's a view to a part of the database, specifically a defined path and all elements directly beneath this path.
This is an abstract class, as it is typed and needs converter functions to transform the data to json and back, as firebase expects a json representation of whatever you want to store there. You can either extend this class and implement the required methods, or you can use FirebaseStore.create and pass callbacks to it to do the same.
- Implemented types
Constructors
- FirebaseStore({required FirebaseStore parent, required String path})
-
Constructs a store from a
parent
store and a subpath
. -
FirebaseStore.api({required RestApi restApi, required List<
String> subPaths}) - Constructs a store from a restApi and a list of subPaths.
-
FirebaseStore.apiCreate({required RestApi restApi, required List<
String> subPaths, required DataFromJsonCallback<T> onDataFromJson, required DataToJsonCallback<T> onDataToJson, required PatchDataCallback<T> onPatchData}) -
Constructs a store from a
restApi
and a list ofsubPaths
with callbacks.factory -
FirebaseStore.create({required FirebaseStore parent, required String path, required DataFromJsonCallback<
T> onDataFromJson, required DataToJsonCallback<T> onDataToJson, required PatchDataCallback<T> onPatchData}) -
Constructs a store from a
parent
store and a subpath
with callbacks.factory
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- path → String
-
The virtual root path of this store.
no setter
- restApi → RestApi
-
The underlying RestApi that is used to communicate with the server.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
subPaths
→ List<
String> -
A raw, segmented representation of path.
final
Methods
-
all(
{ETagReceiver? eTagReceiver}) → Future< Map< String, T> > - Read all entries from the store.
-
create(
T data, {ETagReceiver? eTagReceiver}) → Future< String> - Creates a new entry in the store.
-
dataFromJson(
dynamic json) → T -
A virtual method that converts a
json
object to a data type.override -
dataToJson(
T data) → dynamic -
A virtual method that converts a
data
type to a json object.override -
delete(
String key, {String? eTag, ETagReceiver? eTagReceiver}) → Future< void> - Removes an entry from the store.
-
destroy(
{String? eTag, ETagReceiver? eTagReceiver}) → Future< void> - Deletes everything in the store.
-
keys(
{ETagReceiver? eTagReceiver}) → Future< List< String> > - Lists all keys of the store.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
patchData(
T data, Map< String, dynamic> updatedFields) → T -
A virtual method that applies a set of
updatedFields
on existingdata
.override -
query(
Filter filter) → Future< Map< String, T> > - Queries a subset of entries from the store.
-
queryKeys(
Filter filter) → Future< List< String> > - Queries a subset of keys from the store.
-
read(
String key, {ETagReceiver? eTagReceiver}) → Future< T?> - Read the entry with the given key from the store.
-
streamAll(
) → Future< Stream< StoreEvent< >T> > - Streams all changes in the store.
-
streamEntry(
String key) → Future< Stream< ValueEvent< >T> > - Streams changes of a single entry in the store.
-
streamKeys(
) → Future< Stream< KeyEvent> > - Streams all changes by keys in the store.
-
streamQuery(
Filter filter) → Future< Stream< StoreEvent< >T> > - Streams all changes in the store that match the given filter.
-
streamQueryKeys(
Filter filter) → Future< Stream< KeyEvent> > - Streams all changes by keys in the store that match the given filter.
-
subStore<
U> ({required String path, required DataFromJsonCallback< U> onDataFromJson, required DataToJsonCallback<U> onDataToJson, required PatchDataCallback<U> onPatchData}) → FirebaseStore<U> - Creates a callback based child store to this store.
-
toString(
) → String -
A string representation of this object.
inherited
-
transaction(
String key, {ETagReceiver? eTagReceiver}) → Future< FirebaseTransaction< T> > - Starts a write transaction on the store.
-
update(
String key, Map< String, dynamic> updateFields, {T? currentData}) → Future<T?> - Partially updates an existing entry in the store.
-
write(
String key, T data, {bool silent = false, String? eTag, ETagReceiver? eTagReceiver}) → Future< T?> - Writes the given data to the store.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited