|
import Dexie, { type Table } from 'dexie'; |
|
import type { PicletInstance, Encounter, GameState } from './schema'; |
|
|
|
export class PicletDatabase extends Dexie { |
|
|
|
picletInstances!: Table<PicletInstance>; |
|
encounters!: Table<Encounter>; |
|
gameState!: Table<GameState>; |
|
|
|
constructor() { |
|
super('PicletGameDB'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
this.version(4).stores({ |
|
monsters: '++id, name, createdAt', |
|
picletInstances: '++id, typeId, nickname, isInRoster, rosterPosition, caughtAt', |
|
encounters: '++id, type, createdAt', |
|
gameState: '++id, lastPlayed' |
|
}); |
|
|
|
|
|
this.version(5).stores({ |
|
picletInstances: '++id, typeId, nickname, isInRoster, rosterPosition, caughtAt', |
|
encounters: '++id, type, createdAt', |
|
gameState: '++id, lastPlayed' |
|
}); |
|
} |
|
} |
|
|
|
export const db = new PicletDatabase(); |