cities
Purpose
The cities collection stores geographical and demographic information about cities worldwide.
Its purpose is to provide reference data for location-based features, such as mapping, analytics, and user profiling.
Document schema
{
"admin1_code": "string",
"admin2_code": "string",
"asciiname": "string",
"continent_code": "string",
"coordinates": {
"__lat__": "number",
"__lon__": "number"
},
"country_code": "string",
"country_name": "string",
"createdAt": "timestamp",
"geohash": "string",
"latitude": "number",
"longitude": "number",
"name": "string",
"population": "number"
}
Indexes
This collection does not require external indexes.
Query examples
// Fetch city document by ID
const cityRef = doc(db, "cities", cityId);
const citySnap = await getDoc(cityRef);
// Query all cities in a country
const citiesInIndia = query(
collection(db, "cities"),
where("country_code", "==", "IN")
);
// Query cities by geohash proximity
const citiesNearby = query(
collection(db, "cities"),
where("geohash", ">=", "tsf3"),
where("geohash", "<=", "tsf3~")
);