Skip to main content

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 QEntity and be decorated with @Entity('Name'); the name becomes the Entity static property used by EntityStore.
  • EntityStore.register(...) must run before EntityStore.get/create/init resolve that entity — including in tests that bypass module setup.
  • fill() (called internally by create/init) applies field defaults and runs Hooks.onBeforeFill/onAfterFill; validate() returns per-field validation results and throws ValidationError when returnable is not passed as true.