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

hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
type String
Name of the collection or the sub collection that this repository is accessing.
final

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 document parent. If parent is null, global collection with name type will be used to store the item.
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 of DocumentReferences.
fromSnapshot(DocumentSnapshot<Map<String, dynamic>> snapshot, SnapshotOptions? options) → T
Returns a T (of DBModel) when a snapshot is given. Can return null if the snapshot 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 the specification.
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 the item (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