Skip to content

Commit

Permalink
feat: editMany 메서드 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
n-ryu committed Nov 29, 2022
1 parent 15bc053 commit 4e2520b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions client/src/core/repository/repository.interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@ export interface ITodoListDataBase {
getAll: () => Promise<PlainTodo[]>;
add: (todo: InputTodo) => Promise<PlainTodo[]>;
edit: (id: string, todo: InputTodo) => Promise<PlainTodo[]>;
editMany: (inputArr: Array<{ id: string; todo: InputTodo }>) => Promise<PlainTodo[]>;
remove: (id: string) => Promise<PlainTodo[]>;
}
7 changes: 7 additions & 0 deletions client/src/core/repository/repository.memoryDB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ export class MemoryDB implements ITodoListDataBase {
return [...this.todoList.values()].map((el) => el.toPlain());
}

async editMany(inputArr: Array<{ id: string; todo: InputTodo }>): Promise<PlainTodo[]> {
for (const el of inputArr) {
await this.edit(el.id, el.todo);
}
return [...this.todoList.values()].map((el) => el.toPlain());
}

async remove(id: string): Promise<PlainTodo[]> {
if (!this.todoList.has(id)) throw new Error('ERROR: 삭제하려는 ID의 Todo가 없습니다.');
this.todoList.delete(id);
Expand Down

0 comments on commit 4e2520b

Please sign in to comment.