Data repository

A repository is a layer that encapsulates database access: functions like findById or create that hide the SQL queries. Business services call it without knowing which database is used, which makes testing easier, for example with an in-memory implementation.

Example

const user = await usersRepo.findById(id);

Related concepts

The whole glossary