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, GetOptions? getOptions, SensitiveLogLevel sensitiveLogLevel = SensitiveLogLevel.info}) -
The FirestoreApi requires only a
firebaseFirestore
instance and acollectionPath
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
andid
. -
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< collectionReferenceQuery, required String whereDescription}) → Future<String, dynamic> >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
andsearchField
. -
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
andsearchField
. -
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
andsearchField
. -
findCollection(
) → Query< Map< String, dynamic> > -
Finds a
CollectionReference
of type Map<String, dynamic> based on specified_collectionPath
. -
findCollectionWithConverter(
) → Query< T> -
Finds a
CollectionReference
of typeT
based on specified_collectionPath
. -
findDocRef(
{required String id, String? collectionPathOverride}) → DocumentReference< Map< String, dynamic> > -
Finds a
DocumentReference
of type Map<String, dynamic> based on givenid
. -
findDocRefWithConverter(
{required String id, String? collectionPathOverride}) → DocumentReference< T> -
Finds a
DocumentReference
of typeT
based on givenid
. -
findDocSnapshot(
{required String id, String? collectionPathOverride}) → Future< DocumentSnapshot< Map< >String, dynamic> > -
Finds a
DocumentSnapshot
of type Map<String, dynamic> based on givenid
. -
findDocSnapshotWithConverter(
{required String id, String? collectionPathOverride}) → Future< DocumentSnapshot< T> > -
Finds a
DocumentSnapshot
of typeT
based on givenid
. -
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 givenid
. -
findStream(
) → Stream< QuerySnapshot< Map< >String, dynamic> > -
Finds a Stream of List<Map<String, dynamic>> based on specified
_collectionPath
(all documents). -
findStreamByQuery(
{required CollectionReferenceQuery< Map< ? collectionReferenceQuery, required String whereDescription}) → Stream<String, dynamic> >List< Map< >String, dynamic> > -
Finds a Stream of List<Map<String, dynamic>> based on given
collectionReferenceQuery
andwhereDescription
. -
findStreamByQueryWithConverter(
{CollectionReferenceQuery< T> ? collectionReferenceQuery, required String whereDescription}) → Stream<List< T> > -
Finds a Stream of list of
T
based on givencollectionReferenceQuery
andwhereDescription
. -
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
andid
.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited