ntfy/web/src/app/db.js

22 lines
631 B
JavaScript
Raw Normal View History

import Dexie from 'dexie';
2022-12-02 21:37:48 +01:00
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
2023-01-18 21:50:06 +01:00
// The IndexedDB database name is based on the logged-in user
2022-12-02 21:37:48 +01:00
const dbName = (session.username()) ? `ntfy-${session.username()}` : "ntfy";
const db = new Dexie(dbName);
2022-05-08 01:16:08 +02:00
db.version(1).stores({
2022-03-02 22:16:30 +01:00
subscriptions: '&id,baseUrl',
2022-05-08 01:16:08 +02:00
notifications: '&id,subscriptionId,time,new,[subscriptionId+new]', // compound key for query performance
2022-03-02 04:01:51 +01:00
users: '&baseUrl,username',
prefs: '&key'
});
export default db;