What are Entities in Medusa js

Опубликовано: 01 Май 2026
на канале: ZeeCoding
265
4

@zeecoding
#coding #zeecoding #learncoding #codingforbeginners
Entities in medusa represent tables in the database as classes. An example of this would be the Order entity which represents the order table in the database. Entities provide a uniform way of defining and interacting with data retrieved from the database.

Aside from the entities in the Medusa core package, you can also create custom entities to use in your Medusa backend. Custom entities are TypeScript or JavaScript files located in the src/models directory of your Medusa backend. You then transpile these entities to be used during the backend's runtime using the build command, which moves them to the dist/models directory.

Entities are based on Typeorm’s Entities and use Typeorm decorators. Each entity also require a repository to be created. A repository provides basic methods to access and manipulate the entity's data.