# Class: Model

## M_.Model()

Create a model class. Generally you extends this class like exemple below

## Constructor

#### new Model()

##### Properties:

Name | Type | Description
--- | --- | ---
`fields` | array | the fields definition
`row` | object | the values
`primaryKey` | string | the primary key name

Implements:
  - M_.Observable

##### Example

    M_.ModelKeyVal = class extends M_.Model {
    	getDefinition() {
    		return {
    			primaryKey: "key",
    			fields: [{ name: 'key' }, { name: 'val' }]
    		};
    	}
    };

### Methods

#### createEmptyRow()

Create an empty model

#### get(field)

Get a field

##### Parameters:

Name | Type | Description
--- | --- | ---
`field` | string | The field name

#### getData() → {object}

Get an object that represent the data model

##### Returns:

un nombre

Type
  object

#### getDefinition()

You must extends this class to return a definition

#### getId()

Get the id of row (defined in primaryKey)

#### set(field, val, silently)

Set only one field of model

##### Parameters:

Name | Type | Description
--- | --- | ---
`field` | string | The field name
`val` | something | The value
`silently` | object | Event "update" is not called

#### setRow(row, silently)

Set a object that represent the data model

##### Parameters:

Name | Type | Default | Description
--- | --- | --- | ---
`row` | object |  | The row
`silently` | object | false | Event "update" is not called

#### updateRow() → {type}

##### Returns:

Type
  type