YustDatabaseService class
Handles database requests for Cloud Firestore.
Using FlutterFire for Flutter Platforms (Android, iOS, Web) and GoogleAPIs for Dart-only environments.
- Implementers
Constructors
- YustDatabaseService({DatabaseLogCallback? databaseLogCallback, Client? client, required String envCollectionName, required bool useSubcollections, String? emulatorAddress})
- YustDatabaseService.mocked({required String envCollectionName, required bool useSubcollections, DatabaseLogCallback? dbLogCallback})
Properties
- authClient → Client
-
final
- dbLogCallback ↔ DatabaseLogCallback?
-
getter/setter pair
- envCollectionName → String
-
Represents the collection name for the tenants.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- maxRetries ↔ num
-
Maximum number of retries for a request.
getter/setter pair
- rootUrl → String
-
Root (aka base) URL for the Firestore REST/GRPC API.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- statistics ↔ YustDatabaseStatistics
-
getter/setter pair
- useSubcollections → bool
-
If useSubcollections is set to true (default), Yust is creating Subcollections for each tenant automatically.
final
Methods
-
avg<
T extends YustDoc> (YustDocSetup< T> docSetup, String fieldPath, {List<YustFilter> ? filters, int? limit}) → Future<double> - Returns the sum over a field of multiple documents in a collection.
-
beginTransaction(
) → Future< String> - Begins a transaction.
-
commitEmptyTransaction(
String transaction) → Future< void> -
commitTransaction(
String transaction, YustDocSetup< YustDoc> docSetup, YustDoc doc, {bool useUpdateMask = false}) → Future<void> - Saves a YustDoc and finishes a transaction.
-
count<
T extends YustDoc> (YustDocSetup< T> docSetup, {List<YustFilter> ? filters, int? limit}) → Future<int> - Counts the number of documents in a collection.
-
deleteDoc<
T extends YustDoc> (YustDocSetup< T> docSetup, T doc) → Future<void> - Delete a YustDoc.
-
deleteDocById<
T extends YustDoc> (YustDocSetup< T> docSetup, String id) → Future<void> - Delete a YustDoc by the ID.
-
deleteDocs<
T extends YustDoc> (YustDocSetup< T> docSetup, {List<YustFilter> ? filters}) → Future<void> - Delete all YustDocs in the filter.
-
deleteDocsAsBatch<
T extends YustDoc> (YustDocSetup< T> docSetup, {List<YustFilter> ? filters, List<YustOrderBy> ? orderBy, int? limit}) → Future<int> - Delete all YustDocs in the filter as a batch.
-
get<
T extends YustDoc> (YustDocSetup< T> docSetup, String id) → Future<T?> - Returns a YustDoc from the server, if available, otherwise from the cache. The cached documents may not be up to date!
-
getFirst<
T extends YustDoc> (YustDocSetup< T> docSetup, {List<YustFilter> ? filters, List<YustOrderBy> ? orderBy}) → Future<T?> - Returns the first YustDoc in a list from the server, if available, otherwise from the cache. The cached documents may not be up to date!
-
getFirstFromCache<
T extends YustDoc> (YustDocSetup< T> docSetup, {List<YustFilter> ? filters, List<YustOrderBy> ? orderBy}) → Future<T?> - Returns the first YustDoc in a list from the cache, if available, otherwise from the server. Be careful: The cached documents may not be up to date!
-
getFirstFromDB<
T extends YustDoc> (YustDocSetup< T> docSetup, {List<YustFilter> ? filters, List<YustOrderBy> ? orderBy}) → Future<T?> - Returns the first YustDoc in a list directly from the server.
-
getFirstStream<
T extends YustDoc> (YustDocSetup< T> docSetup, {List<YustFilter> ? filters, List<YustOrderBy> ? orderBy}) → Stream<T?> - Returns a stream of the first YustDoc in a list.
-
getFromCache<
T extends YustDoc> (YustDocSetup< T> docSetup, String id) → Future<T?> - Returns a YustDoc from the cache, if available, otherwise from the server. Be careful: The cached documents may not be up to date!
-
getFromDB<
T extends YustDoc> (YustDocSetup< T> docSetup, String id, {String? transaction}) → Future<T?> - Returns a YustDoc directly from the server.
-
getList<
T extends YustDoc> (YustDocSetup< T> docSetup, {List<YustFilter> ? filters, List<YustOrderBy> ? orderBy, int? limit}) → Future<List< T> > - Returns YustDocs from the server, if available, otherwise from the cache. The cached documents may not be up to date!
-
getListChunked<
T extends YustDoc> (YustDocSetup< T> docSetup, {List<YustFilter> ? filters, List<YustOrderBy> ? orderBy, int pageSize = 300}) → Stream<T> - Returns YustDocs as a lazy, chunked Stream from the database.
-
getListFromCache<
T extends YustDoc> (YustDocSetup< T> docSetup, {List<YustFilter> ? filters, List<YustOrderBy> ? orderBy, int? limit}) → Future<List< T> > - Returns YustDocs from the cache, if available, otherwise from the server. Be careful: The cached documents may not be up to date!
-
getListFromDB<
T extends YustDoc> (YustDocSetup< T> docSetup, {List<YustFilter> ? filters, List<YustOrderBy> ? orderBy, int? limit}) → Future<List< T> > - Returns YustDocs directly from the database.
-
getListStream<
T extends YustDoc> (YustDocSetup< T> docSetup, {List<YustFilter> ? filters, List<YustOrderBy> ? orderBy, int? limit}) → Stream<List< T> > - Returns a stream of a YustDocs.
-
getQuery<
T extends YustDoc> (YustDocSetup< T> docSetup, {List<YustFilter> ? filters, List<YustOrderBy> ? orderBy, int? limit, String? startAfterDocument}) → RunQueryRequest -
getStream<
T extends YustDoc> (YustDocSetup< T> docSetup, String id) → Stream<T?> - Returns a stream of a YustDoc.
-
initDoc<
T extends YustDoc> (YustDocSetup< T> docSetup, [T? doc]) → T - Initializes a document with an id and the time it was created.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
runTransactionForDocument<
T extends YustDoc> (YustDocSetup< T> docSetup, String docId, Future<T?> transaction(T doc), {int maxTries = 20, bool ignoreTransactionErrors = false, bool useUpdateMask = false}) → Future<(bool, T?)> - Reads a document, executes a function and saves the document as a transaction. Returns true if the transaction was successful.
-
saveDoc<
T extends YustDoc> (YustDocSetup< T> docSetup, T doc, {bool? merge = true, bool? trackModification, bool skipOnSave = false, bool? removeNullValues, List<String> ? updateMask, bool skipLog = false, bool doNotCreate = false}) → Future<void> - Saves a document.
-
saveNewDoc<
T extends YustDoc> (YustDocSetup< T> docSetup, {required T doc, Future<void> onInitialised(T)?, bool? removeNullValues}) → Future<T> - Initializes a YustDoc and saves it.
-
sum<
T extends YustDoc> (YustDocSetup< T> docSetup, String fieldPath, {List<YustFilter> ? filters, int? limit}) → Future<double> - Returns the sum over a field of multiple documents in a collection.
-
toString(
) → String -
A string representation of this object.
inherited
-
transformDoc<
T extends YustDoc> (YustDocSetup< T> docSetup, dynamic document) → T? - Transforms a json to a YustDoc
-
updateDocByTransform<
T extends YustDoc> (YustDocSetup< T> docSetup, String id, List<YustFieldTransform> fieldTransforms, {bool skipOnSave = false, bool? removeNullValues}) → Future<void> - Transforms (e.g. increment, decrement) a documents fields.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited