# A Data Layer: One File That Talks to the Database

A data layer keeps every driver call in one file, data/pets.js, whose functions listPets, getPet, addPet and updatePet the routes call without ever touching the driver, turning each document into a plain pet and building filters, a projection, a sort and pages from the query string.

![Cheat sheet: A Data Layer: One File That Talks to the Database](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/11/6ed43cbab44d4489bdbe738cd987f94f.webp)

- Category: MongoDB
- Level: Journeyman
- Tags: mongodb, nodejs, Pagination, Projection, Query String, Repository Pattern
- Author: Gregor Dzierzon
- Updated: November 23, 2026

Source: https://www.ask-codey.com/cheat-sheets/mongodb-driver-a-data-layer-cheat-sheet
