Service to create, update, and retrieve training information.
- Source:
- See:
Methods
(static) addStudent(studentId, teacherId) → {Promise.<boolean>}
Add a student to training.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
studentId |
string
|
The ID of the student to add. |
teacherId |
string
|
The ID of the training. |
Throws:
-
- If the operation fails or encounters an error.
- Type
-
Error
Returns:
- Type:
-
Promise.<boolean>
- Promise that resolves to true if the student was added successfully, or false otherwise.
(static) create(trainingToAdd) → {Promise.<(TrainingDTO|null)>}
Create a training with the provided data.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
trainingToAdd |
*
|
The training data to be added. |
Throws:
-
- If the operation fails or encounters an error.
- Type
-
Error
Returns:
- Type:
-
Promise.<(TrainingDTO|null)>
A promise that resolves to a new TrainingDTO instance representing the created training, or null if creation fails.
(static) delete(id) → {Promise.<boolean>}
Delete training with the provided ID.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
id |
*
|
The ID of the training to delete. |
Throws:
-
- If the operation fails or encounters an error.
- Type
-
Error
Returns:
- Type:
-
Promise.<boolean>
- Promise that resolves to true if the training deleted was successful, or false otherwise.
(static) getAll(offset, limit) → {Promise.<{students: Array.<TrainingDTO>, count: number}>}
Retrieve a paginated list of trainings.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
offset |
number
|
The number of items to skip before starting to return results. |
limit |
number
|
The maximum number of items to return. |
Throws:
-
- If the operation fails or encounters an error.
- Type
-
Error
Returns:
- Type:
-
Promise.<{students: Array.<TrainingDTO>, count: number}>
- A promise that resolves to an object containing an array of TrainingDTO objects representing the teachers and the total count of teachers.
(static) getAllByCategoryId(id) → {Promise.<(Array.<TrainingDTO>|null)>}
Retrieves all trainings belonging to a specific category by category ID.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
id |
*
|
The ID of the category to retrieve trainings for. |
Throws:
-
- If the operation fails or encounters an error.
- Type
-
Error
Returns:
- Type:
-
Promise.<(Array.<TrainingDTO>|null)>
- A promise that resolves to a TrainingDTO object representing the trainings if found, or null if no trainings are found.
(static) getById(id) → {Promise.<(TrainingTO|null)>}
Retrieve the user details with the provided ID.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
id |
*
|
The ID of the training to retrieve. |
Throws:
-
- If the operation fails or encounters an error.
- Type
-
Error
Returns:
- Type:
-
Promise.<(TrainingTO|null)>
- A promise that resolves to a TrainingDTO object representing the training if found, or null if not found.
(static) nameAlreadyExists(name) → {Promise.<boolean>}
Checks if a training with the provided name already exists.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string
|
The name of the training to check for existence. |
Throws:
-
- If the operation fails or encounters an error.
- Type
-
Error
Returns:
- Type:
-
Promise.<boolean>
- A promise that resolves to true if a training with the provided name already exists, or false otherwise.
(static) removeStudent(studentId, trainingId) → {Promise.<boolean>}
Remove student from training.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
studentId |
*
|
The ID of the student to be removed. |
trainingId |
*
|
@param {string} trainingId - The ID of the training from which the student will be removed. |
Throws:
-
- If the operation fails or encounters an error.
- Type
-
Error
Returns:
- Type:
-
Promise.<boolean>
- A Promise that resolves to true if the student removal was successful, or false otherwise.
(static) search(terms) → {Promise.<Array.<TrainingDTO>>}
Search for trainings based on the provided search terms.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
terms |
*
|
The search terms to match against training name. |
Throws:
-
- If the operation fails or encounters an error.
- Type
-
Error
Returns:
- Type:
-
Promise.<Array.<TrainingDTO>>
A promise that resolves to an array of Training objects matching the search terms.
(static) update(id, trainingToUpdate) → {Promise.<boolean>}
Update training with the provided data.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
id |
*
|
The ID of the training to update. |
trainingToUpdate |
*
|
The updated data for the training. |
Throws:
-
- If the operation fails or encounters an error.
- Type
-
Error
Returns:
- Type:
-
Promise.<boolean>
- Promise that resolves to true if the training update was successful, or false otherwise.
(static) updateCover(id, filename) → {Promise.<boolean>}
Updates the cover image for a training with the provided ID.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
id |
string
|
The ID of the training to update the cover image for. |
filename |
string
|
The filename of the new cover image. |
Throws:
-
- If the operation fails or encounters an error.
- Type
-
Error
Returns:
- Type:
-
Promise.<boolean>
- A promise that resolves to true if the cover image update was successful, or false otherwise.