Basic entities
The following are the steps to define a basic entity
:
- Take any class and annotate it with the
@Entity
decorator. - Annotate one of its properties with the
@Id
decorator. - Annotate the rest of fields with the
@Field
decorator.
import { v4 as uuidv4 } from 'uuid'; import { Entity, Id, Field } from 'nukak/entity'; @Entity() export class User { @Id({ onInsert: uuidv4 }) id?: string; @Field() name?: string; @Field() email?: string; @Field() password?: string; }