UserModel

UserModel

new UserModel(name)

Source:

test

Parameters:
Name Type Description
name string

| table name that will be used in all your queries

Extends

Members

(static, constant) propTypes :object

Source:

Defines the default properties types of the UserModel class

Type:
  • object

emailAddress :string|required

Source:

User's email address

Type:
  • string | required

firstName :string

Source:

User's first name

Type:
  • string

lastName :string

Source:

User's last name

Type:
  • string

memberId :int

Source:

reference to the wordpress member

Type:
  • int

membershipId :int

Source:

reference to the wordpress membership

Type:
  • int

registeredAt :date

Source:

Registration date in wordpress

Type:
  • date

username :string|required

Source:

User's username referring to WP

Type:
  • string | required

Methods

create()

Source:

Insert an instance with the validated properties

deleteById(id)

Source:
Inherited From:

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

(async) exists(params)

Source:

Checks if an instance exists based on the parameters passed

Parameters:
Name Type Description
params object

| parameters for the search of the instance

find(params)

Source:

Selects the instances that match the given parameters

Parameters:
Name Type Description
params object

| Parameters to filter the search

insert(props) → {promise}

Source:
Inherited From:

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:
Inherited From:

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

set(props)

Source:

Set and validates user properties

Parameters:
Name Type Description
props object

| Properties of the UserModel object

update()

Source:

Update an instance with the validated properties

updateById(props) → {promise}

Source:
Inherited From:

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:
Inherited From:

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

(async) validateMembership(authorization)

Source:

Validates the membership of a user

Parameters:
Name Type Description
authorization string

| Bearer token found in the request header