-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: IndexedDB 모듈 생성 및 Factory 클래스 구현
- Loading branch information
1 parent
b8a129f
commit d747720
Showing
1 changed file
with
20 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { PlainTodo, InputTodo } from '@todo/todo.type'; | ||
import { ITodoListDataBase } from '@repository/repository.interface'; | ||
import { IDBPDatabase, openDB } from 'idb'; | ||
|
||
const DB_NAME = 'OaO'; | ||
const TABLE_NAME = 'todos'; | ||
|
||
export class IndexedDBFactory { | ||
async createDB(): Promise<IndexedDB> { | ||
const db: IDBPDatabase = await openDB(DB_NAME, 1, { | ||
upgrade(db: IDBPDatabase) { | ||
if (!db.objectStoreNames.contains(TABLE_NAME)) db.createObjectStore(TABLE_NAME); | ||
}, | ||
}); | ||
|
||
return new IndexedDB(db); | ||
} | ||
} | ||
|
||
export class IndexedDB implements ITodoListDataBase { |