Quickstart
import { Entity, Fields, QEntity } from '@quik/entity';
@Entity('User')
export class User extends QEntity {
@Fields.String()
name: string;
@Fields.Email()
email: string;
}
Query the entity's metadata, or instantiate it through the store:
import { EntityStore } from '@quik/entity';
EntityStore.register(User);
const definition = EntityStore.get('User');
const user = EntityStore.create('User', { name: 'Ada', email: 'ada@example.com' });
const results = await user.validate();
Notes
- Entities must extend
QEntityand be decorated with@Entity('Name'); the name becomes theEntitystatic property used byEntityStore. EntityStore.register(...)must run beforeEntityStore.get/create/initresolve that entity — including in tests that bypass module setup.fill()(called internally bycreate/init) applies field defaults and runsHooks.onBeforeFill/onAfterFill;validate()returns per-field validation results and throwsValidationErrorwhenreturnableis not passed astrue.