Framework
Use a custom entity when administrators need to define a new kind of record at runtime. Its definition describes the available fields, while each record holds values for that definition. Start with one real example before deciding which fields people may add later.
Beyond module-defined MikroORM entities, Open Mercato ships an Entities module that implements an Entity-Attribute-Value (EAV) store. It powers runtime configurable objects – think CRM-style records, dynamic forms, or metadata catalogs.
ce.ts – each module can export an entities array describing custom entities and their fields.text, textarea, integer, float, boolean, date, select, relation, attachment) and you can add more via the field registry.modules.generated.ts so runtime registries know which modules supply which custom entities.import { defineFields, cf } from '@open-mercato/modules/dsl';
export const entities = [
{
id: 'example:todo',
title: 'Example Todo',
fields: defineFields([
cf.enum('priority', {
label: 'Priority',
options: ['low', 'medium', 'high'],
}),
cf.boolean('blocked', { label: 'Blocked' }),
]),
},
];
entities module tables. Each record is scoped by entity_id, record_id, organization_id, and tenant_id.cf:<key> syntax (e.g., cf:priority).Use custom entities when you need flexible data structures without shipping a new migration for every customer request.