# new BaseRecord(params, resource)
Parameters:
Name | Type | Description |
---|---|---|
params |
ParamsType | all resource data. I.e. field values |
resource |
BaseResource | resource to which given record belongs |
Members
Methods
# error(path) → {RecordError|null}
Returns error message for given property path (name)
Parameters:
Name | Type | Description |
---|---|---|
path |
string | (name) of property which we want to check if is valid |
validation message of null
# isValid() → {boolean}
Return state of validation for given record
if record is valid or not.
# namespaceParams(prefix) → {object|undefined}
Returns object containing all params keys starting with prefix
Parameters:
Name | Type | Description |
---|---|---|
prefix |
string |
# param(path) → {any}
Returns value for given field.
Parameters:
Name | Type | Description |
---|---|---|
path |
string | path (name) for given field: i.e. 'email' or 'authentication.email' if email is nested within the authentication object in the data store |
value for given field
# populate(propertyName, record)
Populate record relations
Parameters:
Name | Type | Description |
---|---|---|
propertyName |
string | name of the property which should be populated |
record |
BaseRecord | record to which property relates |
# async save() → {Promise.<BaseRecord>}
Saves the record in the database. When record already exists - it updates, otherwise it creates new one.
Practically it invokes BaseResource#create or BaseResource#update methods.
When validation error occurs it stores that to BaseResource#errors
given record (this)
# storeParams(payloadDataopt)
Stores incoming payloadData in record params
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
payloadData |
object |
<optional> |
# title() → {string}
Returns title of the record. Usually title is an value for fields like: email, topic, title etc.
Title will be shown in the breadcrumbs for example.
title of the record
# toJSON(currentAdminopt) → {RecordJSON}
Returns JSON representation of an record
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
currentAdmin |
CurrentAdmin |
<optional> |
# async update(params) → {Promise.<BaseRecord>}
Updates given Record in the data store. Practically it invokes BaseResource.update method.
When validation error occurs it stores that to BaseResource.errors
Parameters:
Name | Type | Description |
---|---|---|
params |
object | all field with values which has to be updated |
given record (this)