mirror of
https://github.com/binwiederhier/ntfy.git
synced 2024-09-28 19:31:59 +02:00
21 lines
631 B
JavaScript
21 lines
631 B
JavaScript
import Dexie from 'dexie';
|
|
import session from "./Session";
|
|
|
|
// Uses Dexie.js
|
|
// https://dexie.org/docs/API-Reference#quick-reference
|
|
//
|
|
// Notes:
|
|
// - As per docs, we only declare the indexable columns, not all columns
|
|
|
|
// The IndexedDB database name is based on the logged-in user
|
|
const dbName = (session.username()) ? `ntfy-${session.username()}` : "ntfy";
|
|
const db = new Dexie(dbName);
|
|
|
|
db.version(1).stores({
|
|
subscriptions: '&id,baseUrl',
|
|
notifications: '&id,subscriptionId,time,new,[subscriptionId+new]', // compound key for query performance
|
|
users: '&baseUrl,username',
|
|
prefs: '&key'
|
|
});
|
|
|
|
export default db;
|