Skip to content
mbroersen edited this page Oct 15, 2020 · 3 revisions

Class

import {Field} from 'jeloquent';

Field: Should be used to fill fields array of model Model constructor

creates magic getters en setters on parent model with the name of the field

Constructor

constructor(name, isPrimaryKey): return Field

//single id primary key
const fields = [
  new Field('id', true) // adds id to parent class adds pk to table
  new Field('name') // adds name to parent class
]

//composed primary key
const fields = [
  new Field('user_id', true) // is part of composed primary key
  new Field('user_type', true) // is part of composed primary key
  new Field('composed_data')
]

Getters

value: get value of field

Setters

value: set model table value of field

Clone this wiki locally