import Dexie from "dexie" import type { DexieTableConfig } from "./DexieTableTypes" import type { ToString } from "./ToString" import { FieldType } from "./DexieTablePrimaryKeyTypes" /** * Based on an object representing the schema, * with the key being the table name & the value being * `DexieTableConfig`, this type represents a runtime * `Dexie` db with proxied table accessors * * @see DexieTableConfig */ export type DexieDatabase = Dexie & { [Name in keyof Schema]: Schema[Name] extends DexieTableConfig< infer T, infer Field > ? Dexie.Table : undefined } : Field extends keyof T ? T[Field] : never > : never } /** * All table names for a database schema */ export type DexieDatabaseTableNames = DB[K] extends Dexie.Table ? K : never