ngyv / re-modelr

A simple-to-use pure javascript object-relational mapping to manage data.
MIT License
0 stars 0 forks source link

Model descriptor to support relationships #20

Open ngyv opened 6 years ago

ngyv commented 6 years ago
{
  id: type('number', { required: true }),
  name:  type('string', { default: 'Nurul' }),
  account: belongsTo('account', { id: 'anotherModelKey' }),
  hobbies: hasMany('hobby', { async: true }),
  partner: hasOne('user', { recursive: true })
}

and then handle it in DomainStore:

Note: isDirty will not take into account the state of the other models (relationships).