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 field
string DB field name property
string Model property name -
_removeField(field, property)
-
Remove a field
Parameters:
Name Type Description field
string DB field name property
string Model property name -
_setField(field, value)
-
Set a field to a value
Parameters:
Name Type Description field
string DB field name value
* New value -
_getField(field)
-
Get field
Parameters:
Name Type Description field
string 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 fields
Array.<string> <optional>
Fields to save options
object <optional>
Options Properties
Name Type Argument Default Description timeZone
string | 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 data
object Raw DB data object options
object <optional>
Options Properties
Name Type Argument Default Description timeZone
string | null <optional>
'UTC' DB time zone