endAtDocument method

Query<T> endAtDocument(
  1. DocumentSnapshot<Object?> documentSnapshot
)

Ends the query results at the document.

Parameters:

  • documentSnapshot: The document to end at.

Returns: A new Query ending at the document.

Example:

query = query.endAtDocument(snapshot);

Implementation

Query<T> endAtDocument(DocumentSnapshot documentSnapshot) {
  Query<T> newQuery = Query<T>(
    helper: QueryHelper(),
    oracledb: _oracledb,
    path: path,
  );
  _helper.dupQuery(newQuery, this);
  String fieldName = newQuery._explicitOrder[0]["field"];
  final dynamic data = documentSnapshot.data() ?? {};
  final value = data[fieldName];
  newQuery._conditions.add({"field": fieldName, "op": "<=", "value": value});
  return newQuery;
}