|
1
|
import Dexie, { Table } from 'dexie'; |
|
2
|
import { Mode } from './AudioPlayer'; |
|
3
|
|
|
4
|
export interface AudioFiles { |
|
5
|
id?: number; |
|
6
|
audioFileId: string, |
|
7
|
type: Mode, |
|
8
|
file: Blob |
|
9
|
} |
|
10
|
|
|
11
|
export class MySubClassedDexie extends Dexie { |
|
12
|
// 'friends' is added by dexie when declaring the stores() |
|
13
|
// We just tell the typing system this is the case |
|
14
|
audioFiles!: Table<AudioFiles>; |
|
15
|
|
|
16
|
constructor() { |
|
17
|
super('splitfireDB'); |
|
18
|
this.version(2).stores({ |
|
19
|
audioFiles: '++id, [audioFileId+type]' // Primary key and indexed props |
|
20
|
}); |
|
21
|
} |
|
22
|
} |
|
23
|
|
|
24
|
export const db = new MySubClassedDexie(); |