-
Notifications
You must be signed in to change notification settings - Fork 123
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
17f6605
commit aefd361
Showing
38 changed files
with
459 additions
and
99 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 @@ | ||
Bug fixes and performance improvements |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -1 +1 @@ | ||
3.0.32 | ||
3.0.33 |
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
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
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
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
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
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,70 @@ | ||
import type { Table, UpdateSpec } from 'dexie'; | ||
|
||
const IGNORED_DEXIE_ERRORS = new Set(['AbortError', 'BulkError', 'UnknownError']); | ||
|
||
async function tryDbQuery<T>(cb: () => Promise<T>) { | ||
try { | ||
return await cb(); | ||
} catch (error: any) { | ||
if (IGNORED_DEXIE_ERRORS.has(error?.name)) return undefined; | ||
else throw error; | ||
} | ||
} | ||
|
||
export class DbRepository<T> { | ||
table: Table<T>; | ||
|
||
constructor(table: Table<T>) { | ||
this.table = table; | ||
} | ||
|
||
all() { | ||
return this.table.toArray(); | ||
} | ||
|
||
find(where: { | ||
[key: string]: any; | ||
}) { | ||
return tryDbQuery(() => { | ||
return this.table.where(where).toArray(); | ||
}); | ||
} | ||
|
||
put(item: T) { | ||
return tryDbQuery(() => { | ||
return this.table.put(item); | ||
}); | ||
} | ||
|
||
bulkPut(items: T[]) { | ||
return tryDbQuery(() => { | ||
return this.table.bulkPut(items); | ||
}); | ||
} | ||
|
||
update(key: string[], update: UpdateSpec<T>) { | ||
return tryDbQuery(() => { | ||
return this.table.update(key, update); | ||
}); | ||
} | ||
|
||
delete(key: string[]) { | ||
return tryDbQuery(() => { | ||
return this.table.delete(key); | ||
}); | ||
} | ||
|
||
deleteWhere(where: { | ||
[key: string]: any; | ||
}) { | ||
return tryDbQuery(() => { | ||
return this.table.where(where).delete(); | ||
}); | ||
} | ||
|
||
clear() { | ||
return tryDbQuery(() => { | ||
return this.table.clear(); | ||
}); | ||
} | ||
} |
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
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
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
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
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
Oops, something went wrong.