This commit is contained in:
Hamcha 2019-09-12 11:34:41 +02:00
parent cf47d5db4a
commit 4486bcb356
Signed by: hamcha
GPG key ID: 44AD3571EB09A39E
2 changed files with 6 additions and 3 deletions

View file

@ -1,10 +1,10 @@
import Dexie from "dexie"; import Dexie from "dexie";
import { Card, CardFilter, StoredImages } from "./types"; import { Card, CardFilter, StoredImage } from "./types";
import { cardFullName } from "./card"; import { cardFullName } from "./card";
class CardDatabase extends Dexie { class CardDatabase extends Dexie {
public cards: Dexie.Table<Card, string>; public cards: Dexie.Table<Card, string>;
public images: Dexie.Table<StoredImages, string>; public images: Dexie.Table<StoredImage, string>;
public constructor() { public constructor() {
super("CardDatabase"); super("CardDatabase");
@ -155,6 +155,9 @@ export async function getCards(filter: CardFilter) {
} }
export async function cardFromIDs(cardIDs: string[]): Promise<Card[]> { export async function cardFromIDs(cardIDs: string[]): Promise<Card[]> {
if (Database == null) {
throw new Error("Database was not initialized, init with 'initDB()'");
}
let table = Database.cards; let table = Database.cards;
//TODO Replace with .bulkGet when upgrading to Dexie 3.x //TODO Replace with .bulkGet when upgrading to Dexie 3.x
return await table return await table

View file

@ -2,7 +2,7 @@ export type Rarity = "C" | "U" | "R" | "SR" | "UR" | "RR";
export type PowerRequirement = { [key: string]: number }; export type PowerRequirement = { [key: string]: number };
export interface StoredImages { export interface StoredImage {
id: string; id: string;
image: Blob; image: Blob;
} }