Basic draft library #19
2 changed files with 6 additions and 3 deletions
|
@ -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
|
||||||
|
|
|
@ -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;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue