# Generic Model

Work in Progress (06/02/2020)

This section is still a work in progress. It will be updated soon.

# Properties

$ready       = false;
/* This promise will resolve once the data is ready */
$promise     = Promise.resolve();
$state       = {};
$dirty       = {};
$invalid     = {};
$id          = null;
$idx         = null;
$noaccess    = null;
_store_name  = name;

# Autogenerated properties

...

# Getters

# get $key

  • $key ⇒ string

Returns a key that can be used for v-for loops:

<li v-for="task in tasklist.items" :key="$key">
  {{task.name}}
</li>

# get $vm

  • $vm ⇒ Vue

(This is only available, if the model definition has getters)

get $vm()

# get $model

  • $model ⇒ GenericStore

Returns the Generic Store which created the model.

get $model()

# get $isValid

  • $isValid ⇒ boolean
$isValid

# get $exists

  • $exists ⇒ boolean
$exists

# Methods

# constructor

  • constructor( ModelDefinition, object, string ) ⇒ GenericModel
constructor( schema, data, name ) {}

# clone

  • clone() ⇒ GenericModel
clone()

# write

  • write() ⇒ Promise
write()

# reset

  • reset() ⇒ null
reset()

# update

  • update( [soft_delete: boolean] ) ⇒ Promise

soft_delete is by default true!

// Update single fields
model.update({ key: 'value' })
model.update({ 'address/zipcode': 12345 })

# setValidationBehaviour

  • setValidationBehaviour( string ) ⇒ null

Valid values are ERROR, WARNING, ELEMENT_VALIDATION, NONE

model.setValidationBehaviour('ERROR')