enhanced_cloud_firestore

Last updated:

0 purchases

enhanced_cloud_firestore Image
enhanced_cloud_firestore Images
Add to Cart

Description:

enhanced cloud firestore

enhanced_cloud_firestore #
A wrapper around the cloud firestore dart package with support for filtering, sorting, limiting, error handling and success scenarios
Getting started #

Add Firebase Core as a dependency in your pubspec.yaml file
In your main.dart file, initialize a firebase app

Usage #
Read data in a collection
final res = EnhancedFirestore.read(collection: 'users');
copied to clipboard
Write data to a collection
final res = EnhancedFirestore.write(
collection: 'users',
payload: {
'name': 'John',
'email': '[email protected]',
'age': '45',
},
)
copied to clipboard
Update data in a collection
final res = EnhancedFirestore.update(
collection: 'users',
payload: {
'name': 'John Cena',
'email': '[email protected]',
'age': '46',
},
filters: [
{
'field': 'email',
'filter': FirestoreFilter.isEqualTo,
'value': '[email protected]',
}
]
)
copied to clipboard
Delete data in a collection
final res = EnhancedFirestore.delete(
collection: 'users',
filters: [
{
'field': 'email',
'filter': FirestoreFilter.isEqualTo,
'value': '[email protected]',
}
]
)
copied to clipboard
Additional Parameters #
All of the above four methods are able to take in the following parameters optionally:


filters - An array of filters to apply on the collection. Specified as a json object list with the following keys ->

field - The document field to apply the filter on
filter - The filter type to apply (is an enum of type FirestoreFilter)
value - The field content to match against





onSuccess - A function which will execute on success scenarios



onError - A function which will execute on error scenarios


The read function can take in the following attributes other than those specified above


sorts - An array of sorts to apply on the collection. Specified as a json object list with the following keys ->

field - The document field to apply the sort on
descending - A boolean value denoting the sort direction (specify as false to sort in ascending order )





limit - A limit on the number of returned records


Caution #


An empty list of filters on an update function will result in the entire collection being updated


An empty list of filters on a delete function will result in the entire collection being deleted



Credits #
Based on the original cloud_firestore package by Google (https://pub.dev/packages/cloud_firestore)

License:

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.