Handles todo-related operations such as creating, updating, and deleting todos.
- Source:
Methods
(async, static) createTodo(req, res) → {Promise.<void>}
The function `createTodo` handles creating a new to-do item by validating input, inserting the data into the database, and sending a response.
Parameters:
Name | Type | Description | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
req |
Object | The HTTP request object, containing information about the incoming request.
Properties
|
||||||||||||||||||||||||
res |
Object | The HTTP response object, used to send the response back to the client. |
- Source:
Throws:
-
- Throws an error if validation fails or if there is an issue with database interaction.
- Type
- Error
Returns:
- A promise that resolves to sending a response to the client.
- Type
- Promise.<void>
(async, static) deleteTodo(req, res) → {Promise.<void>}
The function `deleteTodo` handles deleting an existing to-do item by deleting the data from the database and sending a response.
Parameters:
Name | Type | Description | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
req |
Object | The HTTP request object, containing information about the incoming request.
Properties
|
||||||||||||
res |
Object | The HTTP response object, used to send the response back to the client. |
Throws:
-
- Throws an error if there is an issue with database interaction.
- Type
- Error
Returns:
- A promise that resolves to sending a response to the client.
- Type
- Promise.<void>
(async, static) getTodos(req, res) → {Promise.<void>}
The function `getTodos` handles retrieving a list of to-do items from the database and sending a response.
Parameters:
Name | Type | Description | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
req |
Object | The HTTP request object, containing information about the incoming request.
Properties
|
||||||||||||||||||||||||
res |
Object | The HTTP response object, used to send the response back to the client. |
Throws:
-
- Throws an error if there is an issue with database interaction.
- Type
- Error
Returns:
- A promise that resolves to sending a response to the client.
- Type
- Promise.<void>
(async, static) updateTodo(req, res) → {Promise.<void>}
The function `updateTodo` handles updating an existing to-do item by validating input, updating the data in the database, and sending a response.
Parameters:
Name | Type | Description | ||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
req |
Object | The HTTP request object, containing information about the incoming request.
Properties
|
||||||||||||||||||||||||
res |
Object | The HTTP response object, used to send the response back to the client. |
- Source:
Throws:
-
- Throws an error if validation fails or if there is an issue with database interaction.
- Type
- Error
Returns:
- A promise that resolves to sending a response to the client.
- Type
- Promise.<void>