new BaseModel(db, util)
Create model
Parameters:
| Name | Type | Description |
|---|---|---|
db |
Postgres | MySQL | Mongo | Database service |
util |
Util | Util service |
Properties:
| Name | Type | Description |
|---|---|---|
_dirty |
boolean | Model has been changed flag |
Members
-
<static> provides :string
-
Service name is 'models.base'
Type:
- string
Methods
-
_addField(field, property)
-
Add a field
Parameters:
Name Type Description fieldstring DB field name propertystring Model property name -
_removeField(field, property)
-
Remove a field
Parameters:
Name Type Description fieldstring DB field name propertystring Model property name -
_setField(field, value)
-
Set a field to a value
Parameters:
Name Type Description fieldstring DB field name value* New value -
_getField(field)
-
Get field
Parameters:
Name Type Description fieldstring DB field name Returns:
Returns current value- Type
- *
-
_serialize( [fields] [, options])
-
Convert to object. Dates are converted to strings in UTC timezone
Parameters:
Name Type Argument Description fieldsArray.<string> <optional>
Fields to save optionsobject <optional>
Options Properties
Name Type Argument Default Description timeZonestring | null <optional>
'UTC' DB time zone Returns:
Returns serialized object- Type
- object
-
_unserialize(data [, options])
-
Load data. Dates are expected to be in UTC and are converted into local timezone
Parameters:
Name Type Argument Description dataobject Raw DB data object optionsobject <optional>
Options Properties
Name Type Argument Default Description timeZonestring | null <optional>
'UTC' DB time zone