I am new to firebase and want to use geo querying in my firestore db. the code examples in the docs use an older version of firebase, and I am having a hard time figuring out the equivalent to ".startAt" and ".endAt".
can someone quickly explain how it works in firebase 9?
The startAt()
method includes the start point, while the endAt()
methods to define an end point for your query results.
Sample code startAt()
(Web v9):
import { query, orderBy, startAt } from "firebase/firestore";
const q = query(citiesRef, orderBy("population"), startAt(1000000));
sample code 'endAt()' (Web v9):
import { query, orderBy, endAt } from "firebase/firestore";
const q = query(citiesRef, orderBy("population"), endAt(1000000));
You may want to check this documentation about Paginate data with query cursors.
As mentioned by @Nicholas Tower you can check the other tabs for more examples (Web v9, Web v8, Swift, Obective-C, Java, etc).