FirestoreApi<T extends Object> class

Used to perform all Firestore related CRUD tasks and a little bit more.

Constructors

FirestoreApi({required FirebaseFirestore firebaseFirestore, required String collectionPath(), Map<String, dynamic> toJson(T value)?, T fromJson(Map<String, dynamic> json)?, T fromJsonError(Map<String, dynamic> json)?, bool tryAddLocalId = false, FeedbackConfig feedbackConfig = const FeedbackConfig(), FirestoreLogger firestoreLogger = const FirestoreDefaultLogger(), String createdFieldName = 'created', String updatedFieldName = 'updated', String idFieldName = 'id', String documentReferenceFieldName = 'documentReference', bool isCollectionGroup = false, bool tryAddLocalDocumentReference = false})
The FirestoreApi requires only a firebaseFirestore instance and a collectionPath to work initially.

Properties

collection → CollectionReference<Object?>
The current collection
no setter
doc → DocumentReference<Object?>
A new document
no setter
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
writeBatch → WriteBatch
Helper method to fetch a WriteBatch from _firebaseFirestore..
no setter

Methods

batchCreateDoc({required Writeable writeable, String? id, WriteBatch? writeBatch, TimestampType createTimeStampType = TimestampType.createdAndUpdated, TimestampType updateTimeStampType = TimestampType.updated, bool merge = false, List<FieldPath>? mergeFields, String? collectionPathOverride}) Future<FeedbackResponse<WriteBatchWithReference?>>
Batch creates/writes data based on given writeable.
batchDeleteDoc({required String id, WriteBatch? writeBatch, String? collectionPathOverride}) Future<FeedbackResponse<WriteBatchWithReference?>>
Batch deletes data based on given id.
batchUpdateDoc({required Writeable writeable, required String id, WriteBatch? writeBatch, TimestampType timestampType = TimestampType.updated, String? collectionPathOverride}) Future<FeedbackResponse<WriteBatchWithReference?>>
Batch updates data based on given writeable and id.
createDoc({required Writeable writeable, String? id, WriteBatch? writeBatch, TimestampType createTimeStampType = TimestampType.createdAndUpdated, TimestampType updateTimeStampType = TimestampType.updated, bool merge = false, List<FieldPath>? mergeFields, String? collectionPathOverride, Transaction? transaction}) Future<FeedbackResponse<DocumentReference<Object?>>>
Creates/writes data based on given writeable.
deleteDoc({required String id, WriteBatch? writeBatch, String? collectionPathOverride, Transaction? transaction}) Future<FeedbackResponse<void>>
Deletes data based on given id.
docExists({required String id, String? collectionPathOverride}) Future<bool>
Used to determined if a document exists based on given id.
findAll() Future<FeedbackResponse<List<Map<String, dynamic>>>>
Finds all documents of the specified _collectionPath.
findAllWithConverter() Future<FeedbackResponse<List<T>>>
Finds all documents of the specified _collectionPath.
findById({required String id, String? collectionPathOverride}) Future<FeedbackResponse<Map<String, dynamic>>>
Finds a document based on given id.
findByIdWithConverter({required String id, String? collectionPathOverride}) Future<FeedbackResponse<T>>
Finds a document based on given id.
findByQuery({required CollectionReferenceQuery<Map<String, dynamic>> collectionReferenceQuery, required String whereDescription}) Future<FeedbackResponse<List<Map<String, dynamic>>>>
Finds documents based on a given collectionReferenceQuery.
findByQueryWithConverter({required CollectionReferenceQuery<T> collectionReferenceQuery, required String whereDescription}) Future<FeedbackResponse<List<T>>>
Finds documents based on a given searchTerm and searchField.
findBySearchTerm({required String searchTerm, required String searchField, required SearchTermType searchTermType, bool doSearchNumberEquivalent = false, int? limit}) Future<FeedbackResponse<List<Map<String, dynamic>>>>
Finds documents based on a given searchTerm and searchField.
findBySearchTermWithConverter({required String searchTerm, required String searchField, required SearchTermType searchTermType, bool doSearchNumberEquivalent = false, int? limit}) Future<FeedbackResponse<List<T>>>
Finds documents based on a given searchTerm and searchField.
findCollection() → Query<Map<String, dynamic>>
Finds a CollectionReference of type Map<String, dynamic> based on specified _collectionPath.
findCollectionWithConverter() → Query<T>
Finds a CollectionReference of type T based on specified _collectionPath.
findDocRef({required String id, String? collectionPathOverride}) → DocumentReference<Map<String, dynamic>>
Finds a DocumentReference of type Map<String, dynamic> based on given id.
findDocRefWithConverter({required String id, String? collectionPathOverride}) → DocumentReference<T>
Finds a DocumentReference of type T based on given id.
findDocSnapshot({required String id, String? collectionPathOverride}) Future<DocumentSnapshot<Map<String, dynamic>>>
Finds a DocumentSnapshot of type Map<String, dynamic> based on given id.
findDocSnapshotWithConverter({required String id, String? collectionPathOverride}) Future<DocumentSnapshot<T>>
Finds a DocumentSnapshot of type T based on given id.
findDocStream({required String id, String? collectionPathOverride}) Stream<DocumentSnapshot<Map<String, dynamic>>>
Finds a Stream of type Map<String, dynamic> based on given id.
findDocStreamWithConverter({required String id, String? collectionPathOverride}) Stream<T?>
Finds a Stream of type T based on given id.
findStream() Stream<QuerySnapshot<Map<String, dynamic>>>
Finds a Stream of List<Map<String, dynamic>> based on specified _collectionPath (all documents).
findStreamByQuery({required CollectionReferenceQuery<Map<String, dynamic>>? collectionReferenceQuery, required String whereDescription}) Stream<List<Map<String, dynamic>>>
Finds a Stream of List<Map<String, dynamic>> based on given collectionReferenceQuery and whereDescription.
findStreamByQueryWithConverter({CollectionReferenceQuery<T>? collectionReferenceQuery, required String whereDescription}) Stream<List<T>>
Finds a Stream of list of T based on given collectionReferenceQuery and whereDescription.
findStreamWithConverter() Stream<List<T>>
Finds a Stream of list of T based on specified _collectionPath (all documents).
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
runTransaction<E>(TransactionHandler<E> transactionHandler, {Duration timeout = const Duration(seconds: 30), int maxAttempts = 5}) Future<E>
Helper method to run a Transaction from _firebaseFirestore..
toString() String
A string representation of this object.
inherited
updateDoc({required Writeable writeable, required String id, WriteBatch? writeBatch, TimestampType timestampType = TimestampType.updated, String? collectionPathOverride, Transaction? transaction}) Future<FeedbackResponse<DocumentReference<Object?>>>
Updates data based on given writeable and id.

Operators

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