Entities

Database entity definitions with decorators.

1 min readEdit this page

Example

import { Entity, PrimaryKey, Column, CreatedAt } from '@restjs/orm'
 
@Entity('users')
class User {
  @PrimaryKey()
  id: number
 
  @Column({ type: 'string', length: 255 })
  name: string
 
  @Column({ type: 'string', unique: true })
  email: string
 
  @CreatedAt()
  createdAt: Date
}

Column types

string, text, integer, boolean, timestamp, json, uuid