Class

BaseRecord

BaseRecord(params, resource)

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

Constructor

# 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

View Source adminjs/src/backend/adapters/record/base-record.ts, line 9

Classes

BaseRecord

Members

# errors

Object containing all validation errors: this.errors[path] = 'errorMessage'

View Source adminjs/src/backend/adapters/record/base-record.ts, line 22

PropertyErrors

# errors

Object containing all validation errors: this.errors[path] = 'errorMessage'

View Source adminjs/src/backend/adapters/record/base-record.ts, line 305

# params

Actual record data stored as a flatten object. You shouldn't access them directly - always

with BaseRecord#get and BaseRecord#set property.

View Source adminjs/src/backend/adapters/record/base-record.ts, line 18

ParamsType

# params

Actual record data stored as a flatten object. You shouldn't access them directly - always

with BaseRecord#get and BaseRecord#set property.

View Source adminjs/src/backend/adapters/record/base-record.ts, line 299

# populated

Object containing all populated relations.

View Source adminjs/src/backend/adapters/record/base-record.ts, line 26

object

# populated

Object containing all populated relations.

View Source adminjs/src/backend/adapters/record/base-record.ts, line 311

# resource

Resource to which record belongs

View Source adminjs/src/backend/adapters/record/base-record.ts, line 13

BaseResource

# resource

Resource to which record belongs

View Source adminjs/src/backend/adapters/record/base-record.ts, line 292

Methods

# async create() → {Promise.<BaseRecord>}

Creates the record in the database

Practically it invokes BaseResource#create.

When validation error occurs it stores that to BaseResource#errors

View Source adminjs/src/backend/adapters/record/base-record.ts, line 419

given record (this)

Promise.<BaseRecord>

# 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

View Source adminjs/src/backend/adapters/record/base-record.ts, line 448

validation message of null

RecordError | null

# get(propertyPathopt, optionsopt) → {any}

Returns unflatten (regular) value for given field. So if you have in the params following

structure:

params = {
  genre.0: 'male',
  genre.1: 'female',
}

for get('genre') function will return ['male', 'female']

Parameters:
Name Type Attributes Description
propertyPath string <optional>

path for the property. If not set function returns an entire unflatten object

options GetOptions <optional>

View Source adminjs/src/backend/adapters/record/base-record.ts, line 348

unflatten data under given path

any

# id() → {string|number}

Returns uniq id of the Record.

View Source adminjs/src/backend/adapters/record/base-record.ts, line 425

id of the Record

string | number

# isValid() → {boolean}

Return state of validation for given record

View Source adminjs/src/backend/adapters/record/base-record.ts, line 441

if record is valid or not.

boolean

# namespaceParams(prefix) → {object|undefined}

Returns object containing all params keys starting with prefix
Parameters:
Name Type Description
prefix string
Deprecated:
  • in favour of selectParams

View Source adminjs/src/backend/adapters/record/base-record.ts, line 369

object | undefined

# 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

Deprecated:

View Source adminjs/src/backend/adapters/record/base-record.ts, line 328

value for given field

any

# populate(propertyPath, recordopt) → {void}

Populate record relations
Parameters:
Name Type Attributes Description
propertyPath string

name of the property which should be populated

record BaseRecord | null <optional>

record to which property relates. If record is null or undefined - function clears the previous value

View Source adminjs/src/backend/adapters/record/base-record.ts, line 458

void

# 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

View Source adminjs/src/backend/adapters/record/base-record.ts, line 406

given record (this)

Promise.<BaseRecord>

# selectParams(prefix, optionsopt) → {object|undefined}

Returns object containing all params keys starting with prefix
Parameters:
Name Type Attributes Description
prefix string
options GetOptions <optional>

View Source adminjs/src/backend/adapters/record/base-record.ts, line 380

object | undefined

# set(propertyPath, value)

Sets given value under the propertyPath. Value is flatten and all previous values under this

path are replaced. When value is undefined function just clears the old values

Parameters:
Name Type Description
propertyPath string
value any

View Source adminjs/src/backend/adapters/record/base-record.ts, line 359

an entire, updated, params object

# storeParams(payloadDataopt) → {void}

Stores incoming payloadData in record params
Parameters:
Name Type Attributes Description
payloadData object <optional>

View Source adminjs/src/backend/adapters/record/base-record.ts, line 473

void

# 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 adminjs/src/backend/adapters/record/base-record.ts, line 435

title of the record

string

# toJSON(currentAdminopt) → {RecordJSON}

Returns JSON representation of an record
Parameters:
Name Type Attributes Description
currentAdmin CurrentAdmin <optional>

View Source adminjs/src/backend/adapters/record/base-record.ts, line 465

RecordJSON

# 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

View Source adminjs/src/backend/adapters/record/base-record.ts, line 392

given record (this)

Promise.<BaseRecord>