Skip to main content

Entities

In this document, you'll learn what Entities are in Medusa.

What are Entities

Entities in medusa represent tables in the database as classes. An example of this would be the Copy to Clipboard entity which represents the Copy to Clipboard table in the database. Entities provide a uniform way of defining and interacting with data retrieved from the database.

Aside from Medusa’s core entities, you can also create your own entities to use in your Medusa server. Custom entities are TypeScript or JavaScript files located in the Copy to Clipboard directory of your Medusa server.

Entities are TypeScript files and they are based on Typeorm’s Entities and use Typeorm decorators.

Base Entities

All entities must extend either the Copy to Clipboard or Copy to Clipboard classes. The Copy to Clipboard class holds common columns including the Copy to Clipboard, Copy to Clipboard, and Copy to Clipboard columns.

The Copy to Clipboard class extends the Copy to Clipboard class and adds another column Copy to Clipboard. If an entity can be soft deleted, meaning that a row in it can appear to the user as deleted but still be available in the database, it should extend Copy to Clipboard.

What's Next