Databases / MongoDB
Querying
Indexes, aggregation, pagination, and geospatial queries.
Indexes and query performance in MongoDB
Indexes turn collection scans into range or point lookups. This chapter covers single and compound indexes, the ESR rule, specialty indexes, explain plans, covered queries, creating indexes from TypeScript, and capped and time series collections.
MongoDB Aggregation Framework
Aggregation runs a pipeline of stages that filter, reshape, join, and summarize documents. This chapter covers stage order, grouping and lookups, facets, window functions, writing results with merge or out, views, typed pipelines in TypeScript, memory limits, and why server-side JavaScript stages should be avoided.
Pagination in MongoDB
Listing large collections page by page needs a strategy that stays fast as offsets grow and stays stable when rows are inserted or deleted. This chapter compares offset pagination with keyset cursors, total counts, and a typed paginate helper in TypeScript.
Geospatial queries in MongoDB
Location-aware apps store coordinates as GeoJSON and query them with 2dsphere indexes. This chapter covers point and polygon shapes, near and within operators, geoNear in aggregation, legacy 2d indexes, and a store locator example in TypeScript.