FirestoreModel<T extends Model> class abstract

Mixed in types
Implementers

Constructors

FirestoreModel()

Properties

collectionName String
collection name FirestoreModel use your Model name
no setterinherited
createdAt DateTime?
DateTime when document is created
getter/setter pairinherited
docId String?
document id FirestoreModel will get it for your model
getter/setter pairinherited
hashCode int
The hash code for this object.
no setterinherited
isUpdating bool
getter/setter pair
parentPath String?
we will fill it if model is SubCollection
getter/setter pairinherited
path String?
A string representing the path of the referenced document (relative to the root of the database).
getter/setter pairinherited
perPage int
default items in page
no setterinherited
responseBuilder ResponseBuilder<T>
model mapping to write in collection
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
toMap Map<String, dynamic>
model mapping to write in collection
no setterinherited
updatedAt DateTime?
DateTime when document is updated
getter/setter pairinherited
withTimestamps bool
default true set timestamps
no setterinherited

Methods

all() Future<List<T?>>
To get all documents call all List
arrayRemove({required String field, required List elements, String? docId}) Future<void>
update field realtime value tells the server to remove the given elements from any array value that already exists on the server.
arrayUnion({required String field, required List elements, String? docId}) Future<void>
update field realtime value tells the server to union the given elements with any array value that already exists on the server.
bulkDelete({List<String>? docsIds, Query<Object?> query(Query<Object?> query)?}) Future<void>
delete more one document model call bulkDelete delete specific models use bulkDelete by pass docsIds FirestoreModel.use
bulkUpdate({List<String>? docsIds, required Map<String, Object?> data, Query<Object?> query(Query<Object?> query)?}) Future<void>
create({String? docId}) Future<T?>
To Write in firestore database call create method from your model like this: user.create(); if you have docId for doc: user.create(docId: 'doc_id'); return model after create
decrement({required String field, String? docId, num value = 1}) Future<void>
update field realtime value that tells the server to decrement the field’s current value by the given value.
delete({String? docId}) Future<void>
delete current model call delete user.delete(); delete specific model use delete by pass docId: FirestoreModel.use
exists(String docId) Future<bool>
check if document is exists call exists by docId bool isExists = await FirestoreModel.use
find(String docId) Future<T?>
To get document data by document id call find and pass docId User user = await FirestoreModel.use
first({Query<Object?> queryBuilder(Query<Object?> query)?}) Future<T?>
To get first result from your collection call first you can build your query like where orderBy or any query buildr methods in queryBuilder User firstUser = await FirestoreModel.use
get({Query<Object?> queryBuilder(Query<Object?> query)?, Query<Object?>? query}) Future<List<T?>?>
To get results from your collection call get you can build your query like where orderBy or any query buildr methods in queryBuilder List
getSubCollection(String subCollection, {String? docId, Query<Object?> queryBuilder(Query<Object?> query)?}) Future<List<T?>?>
increment({required String field, String? docId, num value = 1}) Future<void>
update field realtime value that tells the server to increment the field’s current value by the given value.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
paginate({int? perPage, Query<Object?> queryBuilder(Query<Object?> query)?}) Future<List<T?>>
To get results limit and load more as pagination from your collection call paginate you can build your query like where orderBy or any query buildr methods in queryBuilder you can set perPage in your call or set in your model List
remove({required String field, String? docId}) Future<void>
remove field from document
save({String? docId, SetOptions? setOptions}) Future<void>
make changes to your model and call save user.firstName = 'new firstname'; user.save()
streamAll() Stream<List<T?>>?
To stream all documents call streamAll Stream<List
streamFind(String docId) Stream<T?>
To stream document data by document id call streamFind as pass docId Stream
streamFirst({Query<Object?> queryBuilder(Query<Object?> query)?, dynamic onChange(T? dataChange)?}) Stream<T?>
To stream document data by document id call streamFind as pass docId Stream
streamGet({Query<Object?> queryBuilder(Query<Object?> query)?, Query<Object?>? query, dynamic onChange(List<T?> chnagesData)?}) Stream<List<T?>?>
To stream results from your collection call streamGet with queryBuilder Stream<List
streamPaginate({int? perPage, Query<Object?> queryBuilder(Query<Object?> query)?}) Stream<List<T?>>
To stream results from your collection call streamPaginate Stream<List
streamSubCollection(String subCollection, {String? docId, Query<Object?> queryBuilder(Query<Object?> query)?}) Stream<List<T?>?>
subCollection<S extends Model>({String? path}) → S
toString() String
A string representation of this object.
inherited
update({String? docId, required Map<String, Object?> data}) Future<void>
update specific fields in your model call update by pass data user.update(data: { "first_name": "Mohamed", "last_name": "Abdullah" }) update specific model use update by pass docId and data FirestoreModel.use

Operators

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

Static Methods

inject(Object t) → void
Inject your model in FirestoreModel injectsMap FirestoreModel.inject(User())
injectAll(List<Object> list) → void
Inject All Your models
use<T extends Object>() → T
retrieve Your model FirestoreModel.use