Skip to content

Commit

Permalink
refactor(background): add saving words in bulk
Browse files Browse the repository at this point in the history
  • Loading branch information
crimx committed Oct 29, 2018
1 parent de42e3b commit 31421b0
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/background/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,15 @@ export function saveWord ({ area, info }: MsgSaveWord) {
})
}

export function saveWords ({ area, words }: { area: Area, words: Word[] }) {
if (process.env.DEV_BUILD) {
if (words.length !== new Set(words.map(w => w.date)).size) {
console.error('save Words: duplicate records')
}
}
return db[area].bulkPut(words)
}

export function deleteWords ({ area, dates }: MsgDeleteWords) {
return Array.isArray(dates)
? db[area].bulkDelete(dates)
Expand Down

0 comments on commit 31421b0

Please sign in to comment.