Module: controllers/users

Controller module providing logic for managing user entries

Author:
Source:
Example
import { users as usersController } from '/src/controllers';

Methods

(async, static) createOne(request, response, next)

Create a new user record in the database

Parameters:
Name Type Description
request Object

HTTP request object

response Object

HTTP response callback object

next Object

Next route handler callback object

Source:
Throws:
  • Will throw an error if no request.body is passed in.

  • Will throw an error if no createdUser is created.

Returns:

Returns a http response

(async, static) destroyAll(request, response, next)

Destroy all users in the database

Parameters:
Name Type Description
request Object

HTTP request object.

response Object

HTTP response object callback.

next Object

Call the next route callback handler.

Source:
Throws:

Will throw an error if no destroyedUsersCount is created.

Returns:

Will return a count of the users destroyed.

(async, static) destroyOne(request, response, next)

Destroy a user

Parameters:
Name Type Description
request Object

HTTP request object

response Object

HTTP response callback object

next Object

Next route handler callback object

Source:
Throws:
  • Will throw an error if no request.params is passed in

  • Will throw an error if no request.params.id is passed in

Returns:

Returns a http response body

(async, static) readAll(request, response, next)

Read all users within limits, offsets and where filter

Parameters:
Name Type Description
request Object

HTTP request object

response Object

HTTP response callback object

next Object

Next route handler callback object

Source:
Throws:

Will throw an error if no foundUsers created

Returns:

Returns a response body

(async, static) readOne(request, response, next)

Read one user for a given primary key id

Parameters:
Name Type Description
request Object

HTTP request object

response Object

HTTP response callback object

next Object

Next route handler callback object

Source:
Throws:
  • Will throw an error if no request.params is passed in.

  • Will throw an error if no request.params.id is passed in.

Returns:

Returns a response body

(async, static) updateOne(request, response, next)

Update user

Parameters:
Name Type Description
request Object

HTTP request object

response Object

HTTP response callback object

next Object

Next route handler callback object

Source:
Throws:
  • Will throw an error if no request.params is passed in.

  • Will throw an error if no request.params.id is passed it.

  • Will throw an error if no request.body is passed in.

  • Will throw an error if no updatedUser is created.

Returns:

WIll return a http response object