BaseModel

BaseModel

new BaseModel(name)

Source:

Initialize your model with the table name

Parameters:
Name Type Description
name string

| table name that will be used in all your queries

Extends

  • Database

Members

(static) this.error :string|object

Source:

Holds the error related to the current instance

Type:
  • string | object

(static) this.initialized :boolean

Source:

Holds whether or not the instance has been initialized and validated

Type:
  • boolean

(static) this.props :object

Source:

Holds the properties of the current instance

Type:
  • object

Methods

deleteById(id)

Source:

Deletes entries in the table you initialized your class with

Parameters:
Name Type Description
id int

| The identifier of the instance your want to delete

insert(props) → {promise}

Source:

Insert entries in the database table

Parameters:
Name Type Description
props object

| The proprities your entity is composed from

Returns:
Type
promise

select(params) → {promise}

Source:

Select entries from the table you initialized your class with

Parameters:
Name Type Description
params object

| The paramerters of your search in the current entity table

Returns:
Type
promise

updateById(props) → {promise}

Source:

Update entries in the table you initialized your class with

Parameters:
Name Type Description
props object

| The proprities your entity is composed from

Returns:
Type
promise

validate(props) → {string}

Source:

Validates the properties values

Parameters:
Name Type Description
props object

| Props used to initialize the instance

Returns:

| returns the error while validating. It will return null if no error

Type
string