BaseFirestoreApi<T extends BaseFirestoreDto> class
abstract
A generic base class for Firestore API operations.
This class abstracts common CRUD, pagination, and transaction logic
for a specific data type T.
Constructors
- BaseFirestoreApi(FirebaseFirestore firestore)
- Creates an instance of BaseFirestoreApi.
Properties
-
collection
→ CollectionReference<
T> -
The specific
CollectionReferencefor typeT.no setter - firestore → FirebaseFirestore
-
The Firestore instance used for database operations.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
create(
T dto, {Transaction? transaction, DocumentReference< T> ? ref}) → Future<String> - Creates a new document in the collection.
-
delete(
String id) → Future< void> -
Deletes a document from the collection by its
id. -
get(
String id) → Future< T?> -
Fetches a single document by its
id. -
getPaginated(
{DocumentSnapshot< Object?> ? lastDocument, int pageSize = 10, String? orderByField, bool descending = false}) → Future<PaginatedResult< T> > - Fetches a paginated list of documents.
-
newDocumentRef(
[String? id]) → DocumentReference< T> -
Creates a
DocumentReferencewith an optionalid. -
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
runTransaction<
R> (Future< R> action(Transaction transaction)) → Future<R> - Executes a Firestore transaction.
-
toString(
) → String -
A string representation of this object.
inherited
-
update(
T dto, {Transaction? transaction}) → Future< void> - Updates specific fields in a document.
-
watchAll(
) → Stream< List< T> > - Returns a real-time Stream of all documents in the collection.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited