Files
gpx.studio/website/src/lib/db.ts

38 lines
1.0 KiB
TypeScript
Raw Normal View History

2025-06-21 21:07:36 +02:00
import Dexie from 'dexie';
import type { GPXFile } from 'gpx';
import { enableMapSet, enablePatches, type Patch } from 'immer';
2024-05-02 19:51:08 +02:00
2024-05-07 18:14:47 +02:00
enableMapSet();
enablePatches();
2025-06-21 21:07:36 +02:00
export class Database extends Dexie {
2024-05-03 15:59:34 +02:00
fileids!: Dexie.Table<string, string>;
2024-05-07 18:14:47 +02:00
files!: Dexie.Table<GPXFile, string>;
patches!: Dexie.Table<{ patch: Patch[]; inversePatch: Patch[]; index: number }, number>;
2024-05-02 19:51:08 +02:00
settings!: Dexie.Table<any, string>;
overpasstiles!: Dexie.Table<
{ query: string; x: number; y: number; time: number },
[string, number, number]
>;
overpassdata!: Dexie.Table<
{ query: string; id: number; poi: GeoJSON.Feature },
[string, number]
>;
2024-05-02 19:51:08 +02:00
constructor() {
super('Database', {
cache: 'immutable',
2024-05-03 15:59:34 +02:00
});
2024-05-02 19:51:08 +02:00
this.version(1).stores({
2024-05-03 15:59:34 +02:00
fileids: ',&fileid',
files: '',
patches: ',patch',
2024-07-16 23:57:17 +02:00
settings: '',
overpasstiles: '[query+x+y],[x+y]',
2024-07-17 14:19:04 +02:00
overpassdata: '[query+id]',
2024-05-02 19:51:08 +02:00
});
}
}
2024-07-16 23:57:17 +02:00
export const db = new Database();