Skip to content

Commit

Permalink
feat: IndexedDB 모듈 생성 및 Factory 클래스 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
daeseong9388 committed Nov 29, 2022
1 parent b8a129f commit d747720
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions client/src/core/repository/repository.indexedDB.ts
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 {

0 comments on commit d747720

Please sign in to comment.