Class: TodoService

TodoService()

new TodoService()

A class for managing a list of todo items

Source:

Methods

createTodo(contentopt) → {TodoItem}

Create a new Todo item.

Parameters:
Name Type Attributes Default Description
content string <optional>
''

The content of the Todo item.

Source:
Throws:

If the content is empty.

Type
Error
Returns:

The created Todo item.

Type
TodoItem

createTodoTagById(todoId, …tags) → {TodoItem}

Create tags for a todo item by its id.

Parameters:
Name Type Attributes Description
todoId number

The id of the todo item.

tags string <repeatable>

The tags to be added to the todo item.

Source:
Throws:

If the todo item with the given id is not found.

Type
Error
Returns:
  • The updated todo item.
Type
TodoItem

deleteAllTagsById(todoId) → {TodoItem}

Deletes all tags from a todo item.

Parameters:
Name Type Description
todoId number

The id of the todo item to remove tags from.

Source:
Throws:

If the todo item with the specified id is not found.

Type
Error
Returns:
  • The updated todo item with its tags removed.
Type
TodoItem

deleteAllTodo() → {Array.<TodoItem>}

Deletes all todo items in the todoList.

Source:
Returns:
  • The updated todoList (now empty).
Type
Array.<TodoItem>

deleteTagById(todoId, tagId) → {TodoItem}

Deletes a specific tag from a todo item.

Parameters:
Name Type Description
todoId number

The id of the todo item.

tagId number

The id of the tag to delete.

Source:
Throws:

If the todo item or tag with the specified id is not found.

Type
Error
Returns:
  • The updated todo item with the specified tag removed.
Type
TodoItem

deleteTodoById(todoId) → {Array.<TodoItem>}

Deletes a todo item from the todoList by its id.

Parameters:
Name Type Description
todoId number

The id of the todo item to delete.

Source:
Throws:

If the todo item with the specified id is not found.

Type
Error
Returns:
  • The updated todoList.
Type
Array.<TodoItem>

readTodos() → {Array.<TodoItem>}

Read the Todo items.

Source:
Returns:

The Todo items.

Type
Array.<TodoItem>

updateTodoCategoryById(todoId, categoryopt) → {TodoItem}

Update the category of a todo item by its id.

Parameters:
Name Type Attributes Default Description
todoId number

The id of the todo item.

category string <optional>
''

The new category of the todo item.

Source:
Throws:
  • If the todo item with the given id is not found.

    Type
    Error
  • If the category parameter is empty.

    Type
    Error
Returns:
  • The updated todo item.
Type
TodoItem

updateTodoContent(todoId, content) → {TodoItem}

Update the content of a Todo item.

Parameters:
Name Type Description
todoId number

The id of the Todo item.

content string

The new content of the Todo item.

Source:
Throws:

If the Todo item with the specified id is not found.

Type
Error
Returns:

The updated Todo item.

Type
TodoItem

updateTodoIsDone(todoId) → {TodoItem}

Toggle the isDone property of a Todo item.

Parameters:
Name Type Description
todoId number

The id of the Todo item.

Source:
Throws:

If the Todo item with the specified id is not found.

Type
Error
Returns:

The updated Todo item.

Type
TodoItem

updateTodoTagById(todoId, tagId, tagContent) → {TodoItem}

Update a tag for a todo item by its id and tag id.

Parameters:
Name Type Description
todoId number

The id of the todo item.

tagId number

The id of the tag to be updated.

tagContent string

The new content of the tag.

Source:
Throws:
  • If the todo item with the given id is not found.

    Type
    Error
  • If the tag with the given id is not found.

    Type
    Error
Returns:
  • The updated todo item.
Type
TodoItem

TodoService()

new TodoService()

Creates an instance of TodoService.

Source:

Methods

createTodo(contentopt) → {TodoItem}

Create a new Todo item.

Parameters:
Name Type Attributes Default Description
content string <optional>
''

The content of the Todo item.

Source:
Throws:

If the content is empty.

Type
Error
Returns:

The created Todo item.

Type
TodoItem

createTodoTagById(todoId, …tags) → {TodoItem}

Create tags for a todo item by its id.

Parameters:
Name Type Attributes Description
todoId number

The id of the todo item.

tags string <repeatable>

The tags to be added to the todo item.

Source:
Throws:

If the todo item with the given id is not found.

Type
Error
Returns:
  • The updated todo item.
Type
TodoItem

deleteAllTagsById(todoId) → {TodoItem}

Deletes all tags from a todo item.

Parameters:
Name Type Description
todoId number

The id of the todo item to remove tags from.

Source:
Throws:

If the todo item with the specified id is not found.

Type
Error
Returns:
  • The updated todo item with its tags removed.
Type
TodoItem

deleteAllTodo() → {Array.<TodoItem>}

Deletes all todo items in the todoList.

Source:
Returns:
  • The updated todoList (now empty).
Type
Array.<TodoItem>

deleteTagById(todoId, tagId) → {TodoItem}

Deletes a specific tag from a todo item.

Parameters:
Name Type Description
todoId number

The id of the todo item.

tagId number

The id of the tag to delete.

Source:
Throws:

If the todo item or tag with the specified id is not found.

Type
Error
Returns:
  • The updated todo item with the specified tag removed.
Type
TodoItem

deleteTodoById(todoId) → {Array.<TodoItem>}

Deletes a todo item from the todoList by its id.

Parameters:
Name Type Description
todoId number

The id of the todo item to delete.

Source:
Throws:

If the todo item with the specified id is not found.

Type
Error
Returns:
  • The updated todoList.
Type
Array.<TodoItem>

readTodos() → {Array.<TodoItem>}

Read the Todo items.

Source:
Returns:

The Todo items.

Type
Array.<TodoItem>

updateTodoCategoryById(todoId, categoryopt) → {TodoItem}

Update the category of a todo item by its id.

Parameters:
Name Type Attributes Default Description
todoId number

The id of the todo item.

category string <optional>
''

The new category of the todo item.

Source:
Throws:
  • If the todo item with the given id is not found.

    Type
    Error
  • If the category parameter is empty.

    Type
    Error
Returns:
  • The updated todo item.
Type
TodoItem

updateTodoContent(todoId, content) → {TodoItem}

Update the content of a Todo item.

Parameters:
Name Type Description
todoId number

The id of the Todo item.

content string

The new content of the Todo item.

Source:
Throws:

If the Todo item with the specified id is not found.

Type
Error
Returns:

The updated Todo item.

Type
TodoItem

updateTodoIsDone(todoId) → {TodoItem}

Toggle the isDone property of a Todo item.

Parameters:
Name Type Description
todoId number

The id of the Todo item.

Source:
Throws:

If the Todo item with the specified id is not found.

Type
Error
Returns:

The updated Todo item.

Type
TodoItem

updateTodoTagById(todoId, tagId, tagContent) → {TodoItem}

Update a tag for a todo item by its id and tag id.

Parameters:
Name Type Description
todoId number

The id of the todo item.

tagId number

The id of the tag to be updated.

tagContent string

The new content of the tag.

Source:
Throws:
  • If the todo item with the given id is not found.

    Type
    Error
  • If the tag with the given id is not found.

    Type
    Error
Returns:
  • The updated todo item.
Type
TodoItem