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 { Card, CardFilter, StoredImages } from "./types";
import { Card, CardFilter, StoredImage } from "./types";
import { cardFullName } from "./card";
class CardDatabase extends Dexie {
public cards: Dexie.Table<Card, string>;
public images: Dexie.Table<StoredImages, string>;
public images: Dexie.Table<StoredImage, string>;
public constructor() {
super("CardDatabase");
@ -155,6 +155,9 @@ export async function getCards(filter: CardFilter) {
}
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;
//TODO Replace with .bulkGet when upgrading to Dexie 3.x
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 interface StoredImages {
export interface StoredImage {
id: string;
image: Blob;
}