getQuery<T extends Object?> method
Runs query on the backend inside this transaction. Only in a read-only
transaction (runTransaction(..., readOnly: true)): the documents are
those of the snapshot of the database that every read of the transaction
sees.
In a read-write transaction the returned future fails with a
FirestoreException with code invalidArgument: such a transaction verifies
at commit that the documents it read did not change, which is not possible
for the result of a query.
Implementation
Future<QuerySnapshot<T>> getQuery<T extends Object?>(Query<T> query) async {
_validateQuery(query);
final core.Query internalQuery = query.query;
QueryBuilder.validateHasExplicitOrderByForLimitToLast(internalQuery);
final List<Document> documents = await _transaction.runQuery(internalQuery);
return QuerySnapshot<T>(
query,
// The flipped query was sent, see [Query.get].
internalQuery.hasLimitToLast ? documents.reversed.toList() : documents,
);
}