namedQuery method

Future<Query<Map<String, Object?>>?> namedQuery(
  1. String name
)

Reads a Firestore Query from local cache, identified by the given name.

The named queries are packaged into bundles on the server side (along with resulting documents) and loaded to local cache using loadBundle. Once in local cache, you can use this method to extract a query by name. Returns null if there is no query with this name.

await firestore.loadBundle(bundleBytes).future;
final Query<Map<String, Object?>>? latest = await firestore.namedQuery(
  'latest-stories',
);
if (latest != null) {
  final QuerySnapshot<Map<String, Object?>> stories = await latest.get(
    const GetOptions(source: Source.cache),
  );
  print(stories.length);
}

Implementation

Future<Query<Map<String, Object?>>?> namedQuery(String name) async {
  final core.Query? query = await client.getNamedQuery(name);
  return query == null ? null : QueryInternal.create(query, this);
}