28 lines
601 B
TypeScript
28 lines
601 B
TypeScript
import Dexie, { type EntityTable } from 'dexie';
|
|
import { Food } from '../types/food';
|
|
import { FOODS } from './entities/foods';
|
|
import { CHIBIS } from './entities/chibis';
|
|
import { Chibi } from '../types/chibi/chibi';
|
|
|
|
|
|
|
|
const db = new Dexie('ChibiCollector') as Dexie & {
|
|
chibis: EntityTable<Chibi, 'id'>;
|
|
foods: EntityTable<Food, 'id'>;
|
|
};
|
|
|
|
db.version(1).stores({
|
|
chibis: '++id',
|
|
foods: '++id',
|
|
});
|
|
|
|
//db.delete();
|
|
|
|
// Populate with sample data on first run
|
|
db.on('populate', async () => {
|
|
await db.chibis.bulkAdd(CHIBIS);
|
|
await db.foods.bulkAdd(FOODS);
|
|
|
|
});
|
|
|
|
export { db }; |