ChapterController handle with Chapter Resource Api.
Pass a Chapter Object Model(\Models\ChapterModel) to the constructor
of parent class (\Controller\BaseController) for it map the basic database crud operations
to this Object.
Extends
Methods
-
inner getBooksChapters(books) → {json}
-
Get books chapters from chapters ID list
Parameters:
Name Type Description books
array Returns:
json - status and return array list of full chapters. -
inner removeByBookIdList(books) → {json}
-
Remove all chapters inside chapters docs with _books ID that matches list of books
Parameters:
Name Type Description books
array Returns:
json - status and return array list of deleted chapters. -
inner removeChapter(req, res) → {json}
-
RemoveChapter Method. Responds to DELETE /chapter/:bookId/:chapterId. Delete chapter by its ID and remove itself from specific book list. If Success returns 200 status code and a json with the deleted chapter. If error return 400 status code and a json => { errors }. 500 status code only will be returned if the method generates some unexpected error.
Parameters:
Name Type Description req
object Express requisition object. res
object Express response object. Returns:
json - status and return object.- To Do:
-
- Write comments
-
inner save(req, res) → {json}
-
Chapter Save Method. Responds to POST /chapter/:book_id. Saves the chapter with book ID, and then add chapter inside specific book list. If Success returns 200 status code and a json with this.Chapter saved data. If error return 400 status code and a json => { errors }. 500 status code only will be returned if the method generates some unexpected error.
Parameters:
Name Type Description req
object Express requisition object. res
object Express response object. Returns:
json - status and return object.- To Do:
-
- Write comments