initial commit
This commit is contained in:
commit
7e466e29d2
28 changed files with 17360 additions and 0 deletions
35
utils/blocked-site-repo.ts
Normal file
35
utils/blocked-site-repo.ts
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
import type { BlockedSite } from "./types"
|
||||
import type { ExtensionDatabase } from "./database"
|
||||
|
||||
export interface BlockedSitesRepo {
|
||||
getAll(): Promise<BlockedSite[]>
|
||||
getOne(id: string): Promise<BlockedSite | undefined>
|
||||
insert(input: BlockedSite): Promise<void>
|
||||
update(input: BlockedSite): Promise<void>
|
||||
delete(input: BlockedSite): Promise<void>
|
||||
}
|
||||
|
||||
export function createBlockedSitesRepo(_db: Promise<ExtensionDatabase>): BlockedSitesRepo {
|
||||
return {
|
||||
async getAll() {
|
||||
const db = await _db;
|
||||
return await db.getAll("blocked_sites");
|
||||
},
|
||||
async getOne(id) {
|
||||
const db = await _db;
|
||||
return await db.get("blocked_sites", id);
|
||||
},
|
||||
async insert(input) {
|
||||
const db = await _db;
|
||||
await db.add("blocked_sites", input)
|
||||
},
|
||||
async update(input) {
|
||||
const db = await _db;
|
||||
await db.put("blocked_sites", input)
|
||||
},
|
||||
async delete(input) {
|
||||
const db = await _db;
|
||||
await db.delete("blocked_sites", input.id)
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue