Class

BaseRecord

BaseRecord(params, resource)

Representation of an particular ORM/ODM Record in given Resource in AdminBro

Constructor

# new BaseRecord(params, resource)

Parameters:
Name Type Description
params Object

all resource data. I.e. field values

resource BaseResource

resource to which given record belongs

View Source admin-bro/src/backend/adapters/base-record.ts, line 15

Members

BaseResource

# resource

Resource to which record belongs

View Source admin-bro/src/backend/adapters/base-record.ts, line 196

Methods

# error(path) → {String|null}

Returns error message for given property path (name)

Parameters:
Name Type Description
path String

path (name) of property which we want to check if is valid

View Source admin-bro/src/backend/adapters/base-record.ts, line 148

validation message of null

String | null

# id() → {String|Number}

Returns uniq id of the Record.

View Source admin-bro/src/backend/adapters/base-record.ts, line 111

id of the Record

String | Number

# isValid() → {Boolean}

Return state of validation for given record

View Source admin-bro/src/backend/adapters/base-record.ts, line 134

if record is valid or not.

Boolean

# namespaceParams(prefix) → {Object}

Returns object containing all params keys starting with prefix

Parameters:
Name Type Description
prefix String

View Source admin-bro/src/backend/adapters/base-record.ts, line 45

Object

# 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

View Source admin-bro/src/backend/adapters/base-record.ts, line 28

value for given field

any

# 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

View Source admin-bro/src/backend/adapters/base-record.ts, line 157

# async save() → {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

View Source admin-bro/src/backend/adapters/base-record.ts, line 88

given record (this)

BaseRecord

# storeParams()

Stores incoming payloadData in record params

View Source admin-bro/src/backend/adapters/base-record.ts, line 140

# 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.

View Source admin-bro/src/backend/adapters/base-record.ts, line 126

title of the record

String

# toJSON(currentAdmin) → {RecordJSON}

Returns JSON representation of an record

Parameters:
Name Type Description
currentAdmin CurrentAdmin

View Source admin-bro/src/backend/adapters/base-record.ts, line 165

RecordJSON

# async update(params) → {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

View Source admin-bro/src/backend/adapters/base-record.ts, line 62

given record (this)

BaseRecord