Skip to content

Commit

Permalink
feat: IndexedDB edit, editMany 메서드 구현 resolve #121
Browse files Browse the repository at this point in the history
  • Loading branch information
daeseong9388 committed Nov 29, 2022
1 parent 482531c commit 788c300
Showing 1 changed file with 13 additions and 3 deletions.
16 changes: 13 additions & 3 deletions client/src/core/repository/repository.indexedDB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,21 @@ export class IndexedDB implements ITodoListDataBase {
return await this.getAll();
}

async edit(id: string, todo: InputTodo): Promise<PlainTodo[]> {
const tx = this.db.transaction(TABLE_NAME, 'readwrite');
const store = tx.objectStore(TABLE_NAME);
const oldTodo = (await this.get(id)) as PlainTodo;
const newTodo = new Todo({ ...oldTodo, ...todo, id: oldTodo.id }).toPlain();
await store.put(newTodo, newTodo.id);
return await this.getAll();
}

async edit(id: string, todo: InputTodo): Promise<PlainTodo[]> {}

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

async remove(id: string): Promise<PlainTodo[]> {}
}

0 comments on commit 788c300

Please sign in to comment.