FirebaseRepository<T extends DBModelI> class
abstract
A repository that can be used to add, query, update and delete document from Firestore.
Should implement FirebaseRepository.fromSnapshot and FirebaseRepository.toMap to work with the given type of DBModel
Constructors
- FirebaseRepository(String type)
- A repository that can be used to add, query, update and delete document from Firestore.
Properties
Methods
-
add(
{required T item, SetOptions? setOptions, DocumentReference< Object?> ? parent}) → Future<DocumentReference< Object?> > -
Given
item
will be added to the collection with name type, which is inside the documentparent
. Ifparent
is null, global collection with name type will be used to store theitem
. -
addList(
{required Iterable< T> items, DocumentReference<Object?> ? parent}) → Future<void> -
Same as FirebaseRepository.add but will store a Iterable of given
items
and return a Iterable ofDocumentReference
s. -
fromSnapshot(
DocumentSnapshot< Map< snapshot, SnapshotOptions? options) → TString, dynamic> > -
Returns a
T
(of DBModel) when asnapshot
is given. Can return null if thesnapshot
is in bad format. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
query(
{required QueryTransformer spec, DocumentReference< Object?> ? parent, bool includeMetadataChanges = false}) → Stream<Iterable< T> > -
Query some data from a Firestore collection with name type in the
document with
DocumentReference
parent
according to the given rule in thespecification
. -
queryGroup(
{required QueryTransformer spec, required String collectionPath, bool includeMetadataChanges = false}) → Stream< Iterable< T> > - Usage is as same as in the FirebaseRepository.query, but this is for collection group querying.
-
queryGroupSingle(
{required QueryTransformer spec, required String collectionPath, Source source = Source.serverAndCache}) → Future< Iterable< T> > - Same as FirebaseRepository.queryGroup but instead of returning a Stream this will return a Future with the latest values in the Firestore.
-
querySingle(
{required QueryTransformer spec, DocumentReference< Object?> ? parent, Source source = Source.serverAndCache}) → Future<Iterable< T> > - Same as FirebaseRepository.query but instead of returning a Stream this will return a Future with the latest values in the Firestore.
-
remove(
{required T item}) → Future< void> -
Delete the document corresponding to the
item
. If the reference of theitem
(DBModel.ref) is null nothing will happen. -
toMap(
T value, SetOptions? options) → Map< String, Object?> -
Converts the given
item
to a Map that can be stored in Firestore. -
toString(
) → String -
A string representation of this object.
inherited
-
update(
{required T item, SetOptions? setOptions, DocumentReference< Object?> ? parent, MapperCallback<T> ? mapper}) → Future<DocumentReference< Object?> > -
Update the document which is corresponding to the given
item
.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited