# Keeping Database Code in One Place

A repository module is the one file in an API that talks to MongoDB, with functions such as create and get that give back plain objects whose id is text, so the routes never need to know how the data is stored.

![Cheat sheet: Keeping Database Code in One Place](https://fsdtrainingmedia.blob.core.windows.net/public/images/2026/11/0ff4595664ef414abc0bbe3d41284baa.webp)

- Category: Node.js
- Level: Journeyman
- Tags: \_id and ObjectId, Data Access Object (DAO), mongodb, nodejs, Repository Pattern, Separation of Concerns
- Author: Gregor Dzierzon
- Updated: November 23, 2026

Source: https://www.ask-codey.com/cheat-sheets/node-mongodb-repository-module-cheat-sheet
